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
Define a method convertToLiters() that has two integer parameters as the number of gallons and quarts. The method returns a double as the volume converted to liters, given that:
- 1 quart = 0.946353 liters
- 1 gallon = 4 quarts
Ex: If the input is 2 56, then the output is:
Result: 60.567 liters
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.util.Scanner;
public class VolumeConversion {
/* Your code goes here */
publicstaticvoidmain(String[] args) {
Scannerscan=newScanner(System.in);
intnumGallons;
intnumQuarts;
numGallons=scan.nextInt();
numQuarts=scan.nextInt();
// Print with value rounded to 3 decimal places
System.out.printf("Result: %.3f liters\n", convertToLiters(numGallons, numQuarts));
}
}
SAVE
AI-Generated Solution
info
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
Unlock instant AI solutions
Tap the button
to generate a solution
to generate a solution
Click the button to generate
a solution
a solution
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
- Write in Java using Methods Create two methods under the Main class. One prints “I am mighty!”, and the other one accepts an integer input and prints “I am {integer} times stronger than you!”. Call the first method and then, accept an integer input and use that to call the second method. Inputs 1. Line containing a string 9000 Sample Output Enter a number: 99999 I am mighty! I am 99999 times stronger than you!arrow_forwardA pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output is the miles walked. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue); Ex: If the input is: 5345 the output is: 2.67 Your program must define and call a method:public static double stepsToMiles(int userSteps) Code: import java.util.Scanner; public class LabProgram {/* Define your method here */public static void main(String[] args) {/* Type your code here. */}}arrow_forward1. write a static method that receive as parameter an array of type student and print the names of all students excepted to graduate. The student is expected to graduate if he/she in year 4 and GPA >2. 2. Write a java program that: a. Asks the user to enter the number of the Student, then the data of each Student and store then inside an array of type Student. b. Ask the user to read a value d of type double then displays the name of all the Student who have GPA greater than the value d. c. Call the above method and print the name of student who excepted to graduate.arrow_forward
- Write a java method that receives two integers called n1 and n2 and then returns the number of rotations of digits to the left or to the right so that n1 and n2 becomes the same. if not possible the method returns your student ID number.arrow_forwardI need to use java program. I need to solve this question quickly.arrow_forwardWrite a method in Java that checks if input is actually an integer and is greater than or equal to 0arrow_forward
- ) Write a Java method that prints integers from 1 to 100 (see the output). Use the following output as a guide:arrow_forwardJava programming Write a method (void banana(int a)) that draws the following figure: a triangle with alternating digits 1/0 in upper right corner: Example for a=6: 101010 010101 001010 000101 000010 000001 Example for a=3: 101 010 001arrow_forwardWhat should happen if the processor issues a request during block writing from the write buffer to main memory and the request is satisfied by the cache?arrow_forward
- need help writing the program n passed to method as a parameter. Assume N is an even number with disply pattern of n/2 rows as shown in image.arrow_forwardThe Java code given below implements the method named showTwos that shows the factors of 2 in a given integer. Change it in a way, that it can work for negative input as well. (Try to not change the main structure). import java.util.Scanner;public class ShowTwos {public static void main(String[] args) {// write your code hereScanner input = new Scanner(System.in);int num = input.nextInt(); if (num >=2){System.out.print(showTwos(num));}else {System.out.println("Enter valid number");}} public static String showTwos(int number){// write your code hereString result = Integer.toString(number);result+=" = ";int c = 0;while (number % 2 == 0){number = number / 2;c+=1;} if (c > 0){for (int i=0; i<c;i++){result+="2 * ";}} result+=Integer.toString(number); return result;}}arrow_forwardDefine a static void method, which receives as an parameter an array of salaries (of type double) and increases them as follows • salaries <$ 800 - by 10% • 800 <= salaries <= $1500 - by 5% • salaries over $1,500 - by 3% In the test function, define an initialized array of salaries and display it. Call the written method and display the array again.arrow_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