
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
Constantly ask the user for a number. End the program when zero is entered.
Write a code in Java that results like test case 1

Transcribed Image Text:Test Case 1
Enter zero to exit: \n
2 ENTER
Enter zero to exit: \n
4 ENTER
Enter zero to exit: \n
6 ENTER
Enter zero to exit: \n
8 ENTER
Enter zero to exit: \n
0 ENTER
Test Case 2
Enter zero to exit: \n
324 ENTER
Enter zero to exit: \n
234 ENTER
Enter zero to exit: \n
6 ENTER
Enter zero to exit: \n
-10 ENTER
Enter zero to exit: \n
3 ENTER
Enter zero to exit: n
4 ENTER
Enter zero to exit: \n
5 ENTER
Enter zero to exit: \n
0 ENTER

Transcribed Image Text:Test Case 3
Enter zero to exit: \n
0 ENTER
Test Case 4
Enter zero to exit:\n
16JENTER
Enter zero to exit: \n
0ENTER
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Similar questions
- Write Java statements to do the following (Make sure to number your answers): Define a constant PI initialized to 3.14159265 and a constant e initialized to 2.718282.Define the variables n as an integer, and factorial as a double.Assign the value 25 to the variable n.Include a comment "Stirling's formula".Write an assignment statement using the Stirling's formula provided below to calculate and assign the result to the variable factorial.??2??√?? 6. Display the result with three decimal places on the console.arrow_forwardhow do i write this in javaarrow_forwardPlease write the following in Java (If and switch statements). Enter an integer: 27 Is 27 an even number? False Enter an integer: 60 Is 60 an even number? Truearrow_forward
- Instructions from your teacher: Write a program that asks the user to enter a character. Then pass the character to the following methods. changeCase() – if the character is lower case then change it to upper case and if the character is in upper case then change it to lower case. Example output is given below: Enter a character a a is equivalent to A Note: Java represents character using Unicode encoding and ‘A’ to ‘Z’ is represented by numbers 65 to 90 and ‘a’ to ‘z’ is represented by numbers 97 to 122. So to convert ‘A’ to ‘a’ you need to add (97-65) to A and then cast it to Character type since the addition will change its type to integer. You can use the following code to read a character from console. When you call charAt(i) method for any String it returns the character at index i. The index of first character is 0, the index of second character is 1 and so on. Scanner input = new Scanner(System.in); char ch =input.next().charAt(0); If you…arrow_forwardHey all, Need some help on best way to go about this question. All coding is done in Java. I am using the IntelliJ Idea, as the base for the code if it helps. Question is as follows: A car’s miles-per-gallon (MPG) can be calculated with the following formula: MPG = Miles driven / Gallons of gas used Write a java program that prompts the user for the number of miles driven and the gallons of gas used. It should calculate the car’s miles-per-gallon and display the result on the screen.arrow_forward
arrow_back_ios
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