Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Initialize a variable for the row, and set it to zero. Then, create a for loop from 0 to the total number or rows, then within the for loop, create a conditional that says that if the first and second entry of the array at the index of that iteration number is equal to the longitude and latitude respectively, then the value of row equals the number of the iteration. How do I do the section in bold? Here is my code so far:
public static int[] oneMonthGenerator(double longitute, double latitude, int month, double[][] drywet, double[][] wetwet) {
for (int row = 0; row < 4001; row++) {
if (longitute == drywet[row][0] && latitude == drywet[row][1]) {
row = -----> ?
} else if (longitute == wetwet[row][0] && latitude == drywet[row][1]) {
row = -----> ?
}
}
Expert Solution
arrow_forward
Step 1 Given
public static int[] oneMonthGenerator(double longitute, double latitude, int month, double[][] drywet, double[][] wetwet) {
for (int row = 0; row < 4001; row++) {
if (longitute == drywet[row][0] && latitude == drywet[row][1]) {
row = -----> ?
} else if (longitute == wetwet[row][0] && latitude == drywet[row][1]) {
row = -----> ?
}
}
The above method is given in the question.
The question is to assign the number of the iteration in the loop to the variable 'row'. So in order to keep track of the number of iteration let us define another variable.
int i = 1;
The above method is given in the question.
The question is to assign the number of the iteration in the loop to the variable 'row'. So in order to keep track of the number of iteration let us define another variable.
int i = 1;
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please help me with my assignment, I need to submit it by tonight. I don't get an output with my list, please help. def make_pizza(*toppings):"""Print the list of toppings that have been requested."""print("\nMaking a pizza with the following toppings:")make_pizza(*topping('pepperoni','mushroom','green peppers','extra cheese')print(make_pizza()[1])arrow_forwardin java String inputWord is read from input. Write a while loop that iterates until inputWord is equal to "Finale". In each iteration of the loop: Read integer clothingNumber from input. If clothingNumber is less than 30, output the value of inputWord, followed by ": low on stock" and a newline. Otherwise, output the value of inputWord, followed by ": well stocked" and a newline. Read string inputWord from input. Click here for example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; public class PairedDataProcessing { publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); StringinputWord; intclothingNumber; inputWord=scnr.next(); /* Your code goes here */ } }arrow_forwardA credit card company awards monthly reward points (integer type) based on the type of membership a customer has and the amount they charge to their card that month. The user will enter the membership type and purchase amount, then determine the appropriate number of reward points. Use a pretest loop to allow the user to enter data until they input 0 for the purchase amount. Do all of your output in main(). Make it look like this. Don’t forget your underlines won’t be immediately underneath. Use methods for the following: getPurchaseAmt() Get the monthly purchase amount from the user. Include an error-trap around this input value so the user will have to enter a positive number (0r 0 to end the loop). Return the purchase amount. displayMenu() Display a menu of the membership types for the user to choose from, as follows: Membership Types: Premium Plus Standard Enter choice (1, 2, or 3): This method only displays. There is nothing to return, so it will be a void method. You will…arrow_forward
- The project contains three (3) arrays already declared and initialized. You need to implement the following fivemethods in the sections indicated by the comments: Method printo Parameter: An array of integers and number of elements.o Prints out all the elements of the array on the same line and separated by a space. o See format in the sample output shown below. Method printLargesto Parameter: An array of integers and number of elements.o Use a FOR loop to find the largest element in the array.o Call the method print to print out the entire array.o Print the largest element as shown in the sample output. Method printAllEvenso Parameter: An array of integers and number of elements.o Call the method print to print out the entire array.o Use a FOR loop to print out all the even numbers in the array. Numbers should be on the sameline and separated by a space.o See format in the sample output shown below. Method printSumo Parameter: An array of integers and number of elements.o Call the…arrow_forwardIn Python IDLE: How would I write a function for the problem in the attached image?arrow_forwardThe loop below is intended to collect all characters that occur more than once in a given string. When you try it out with a string such as “Mississippi”, you will note that that letters that occur three or more times are collected more than once. Modify the loop so that each repeated letter is collected exactly once. For example, when s is “Mississippi”, result should be “si” and not “sissii” Only allowed to edit code in the /* Your code goes here */ portion. Thanks for the help!arrow_forward
- text file 80 1 2 3 100 100 100 1001 0 2 100 3 4 100 1002 2 0 4 4 100 5 1003 100 4 0 100 100 4 100100 3 4 100 0 3 3 3100 4 100 100 3 0 100 1100 100 5 4 3 100 0 2100 100 100 100 3 1 2 0 My code below. I am getting an error when trying to create my adjacency matrix. i dont know what i am doing wrong def readMatrix(inputfilename): ''' Returns a two-dimentional array created from the data in the given file. Pre: 'inputfilename' is the name of a text file whose first row contains the number of vertices in a graph and whose subsequent rows contain the rows of the adjacency matrix of the graph. ''' # Open the file f = open(inputfilename, 'r') # Read the number of vertices from the first line of the file n = int(f.readline().strip()) # Read the rest of the file stripping off the newline characters and splitting it into # a list of intger values rest = f.read().strip().split() # Create the adjacency matrix adjMat = []…arrow_forwardYou will build a program to manage a race car in this assessment. The code will consist of a for-loop method that will run a car around a race track and cause “wear and tear” on the car. The car will perform x number of laps and will have to make pitstops when it either runs out of gas or needs a tire replacement. The for loop will be simple def wear_tires(car): tire -=1 def use_gas(car): gas -=1 c = Car() # You need to make this part for i in range(100): if the car needs a pitstop: perform pitstop else: wear_tires(c) use_gas(c) # Display the current cars wear in a much better format print(c.tire) print(c.gas) print(“Current Lap is: “ , i) For this task, you will have to use this for loop and build out the two methods in the main Python program. To use the above code, you must build two pieces of information. An abstract Vehicle class A Car class A RaceCar class Each with its methods and variables. This programming will involve using inheritance and abstraction to make a race car…arrow_forwardWrite a program using while loop and for loops to print first 50 prime numbers in 5 lines, each line containing 10 numbers. 1. Create a program called CountCharacters.java. 2. At the top of your java file add the following documentation comments. Replace the italicized text with the appropriate content. /** @author Your Name CS 110 Section 012 Lab 9 Final Today's Date 3. Import the Scanner class and ask user to enter a line. Implement the while loop so that the user can input any number of lines and one line at a time. To stop entering lines, the user can write "quit. (Hint: Use the string method <str>.equals() in the while condition to stop the while loop OR a break keyword). 4. Implement the for loop inside the while loop to iterate through the line one character at a time to count and output the number of blank spaces, alphabetic characters, digit characters, and other characters in all the lines. You need to use different methods of character class like charAt(), isDigit(),…arrow_forward
- Complete the rotate_text() function that takes 2 parameters, a string data and an integer n. If n is positive, then the function will shift all the characters in data forward by n positions, with characters at the end of the string being moved to the start of the string. If n is 0 then the text remains the same. For example: rotate_text('abcde', rotate_text('abcde', rotate_text('abcde', 1) would return the string 'eabcd' 3) would return the string 'cdeab' 5) would return the string 'abcde' rotate_text('abcde', 6) would return the string 'eabcd' ... and so on. If n is negative, then the function will shift the characters in data backward by n positions, with characters at the start of the string being moved to the end of the string. For example: rotate text('abcde', -1) would return the string 'bcdea'arrow_forwardReview Loops Write a java program to ask three people three questions about name, number of courses, and number of credit hours. Also, print result in columns as below. Note: the input.nextInt() method reads only the integer value from input buffer.The "\n" is still staying in the input buffer. If you continue reading with input.nextLine(),you will receive the "\n" and CPU will not wait for any input. To fix this problem, you addthe statement input.nextLine() to flush out the "\n" from the input buffer.arrow_forwardJAVA A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly. Take an integer n as input from the keyboard, print true if n is a perfect number, otherwise, print false. You do not need to print any explanation, just print true or false. Use a for loop to generate the divisors. Example 1: Input: num = 28 Output: true Explanation: 28 = 1 + 2 + 4 + 7 + 14 1, 2, 4, 7, and 14 are all divisors of 28. Example 2: Input: num = 6 Output: true Example 3: Input: num = 496 Output: true Example 4: Input: num = 8128 Output: true Example 5: Input: num = 2 Output: falsearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education