Concept explainers
- 1. Read the problem statement.
- 2. Formulate the
algorithm using pseudocode and top-down, stepwise refinement. - 3. Write a Java
program . - 4. Test, debug and execute die Java program.
- 5. Process three complete sets of data.
(Gas Mileage) Drivers are concerned with the mileage their automobiles get. One driver has kept track of several trips by recording the miles driven and gallons used for each tankful. Develop a Java application that will input the miles driven and gallons used (both as integers) for each trip. The program should calculate and display the miles per gallon obtained for each trip and print the combined miles per gallon obtained for all trips up to this point. All averaging calculations should produce floating-point results. Use class Scanner and sentinel-controlled iteration to obtain the data from the user.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Additional Engineering Textbook Solutions
Starting out with Visual C# (4th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Artificial Intelligence: A Modern Approach
Starting Out With Visual Basic (8th Edition)
Starting Out with Python (4th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- 1.Write Java statements to accomplish each of the following tasks: (a) Assign the product of variables b and c to the int variable a. (b) Displaying texts with printf. (c) Compiling and Executing Java program. 2.Write a Java program that displays the text "This is Java Class " and "My first program in Java" also insert comments to display your Name and Student number. 3.Draw and explain a UML class diagram for a class Fruit.arrow_forwardplease use java and keep the solution and code very basic Q1-Solve this easy question(i)Indicate the display the computer carries out when it executes the code of each System.out.printf statement for the two fragments: System.out.printf("%3.1f - %3.1f = %4.2f\n", 6.51, 4.92, 1.59); int1 = 8; int2 = 3; product= int1 * int2; System.out printf("The product of %d and %d is %d. In", int1, int2, product): (ii)Write a fragment of syntactically correct Java code that contains the following (in the order specified):1. a one-line comment whose text is Here are the variables2. followed by a single blank line3. followed by the declaration of the following 4 variables with one variable declared per line:•o anint of type int* aDouble of type double* aString of type String* aChar of type char (iii) From the following list of character sequences, there are reserved words, identifiers for variables or methods, identifiers for constants, and "invalid" sequences don't apply…arrow_forwardNeed help with this first problem!! any help is greatly appreciated!! Thank you so much! 1. Write each exercise in Java program -Write a program that outputs three lines: your full name the full name of the programmer who created Java Java rocks! -Write a program that prints the result of this expression. (12.5 + 5.5 / 3) / (6.25 * 6 - 5.0) - Write a program that prompts the user to enter a weight in kilograms and then displays the equivalent weight in pounds. Control of decimal places is not required.arrow_forward
- Please write in Java and use Math.PI for pi. I wrote the print statements to use in the program. The screenshot explains the question.arrow_forwardALL INPUTS AND OUTPUTS OPERATIONS MUST BE DONE USING THEJOPTIONPANE. all codes in java Last month Joe purchased some stock in Acme Software, Inc. Here are the details of thepurchase:• The number of shares that Joe purchased was 1,000.• When Joe purchased the stock, he paid $32.87 per share.• Joe paid his stockbroker a commission that amounted to 2% of the amount he paidfor the stock.Two weeks later Joe sold the stock. Here are the details of the sale:• The number of shares that Joe sold was 1,000.• He sold the stock for $33.92 per share.• He paid his stockbroker another commission that amounted to 2% of the amount hereceived for the stock.Write a program that displays the following information:• The amount of money Joe paid for the stock. • The amount of commission Joe paid his broker when he bought the stock. • The amount that Joe sold the stock for. • The amount of commission Joe paid his broker when he sold the stock. • Display the amount of profit that Joe made after selling his…arrow_forwardWrite the programs, execute and show the output Take the screenshot of the programs along with the output Q1. Write a Java program to calculate greatest of three quiz marks. UML Diagram:QuizBestQuiz1:intQuiz2:intQuiz3:intBestQuiz(int,int,int):intarrow_forward
- Lesson 7: Using Prewritten Classes and Methods – JavaProgramming 1. Write a Java program to determine the answers to the following: a. The squre of 30 b. The sine and cosine of 100 c. The value of the floor, ceiling and round of 44.7 d. The larger and smaller of the character K and integer 70 2.Write a program to calculate how many days it is from today until the current year 3. Write a program to determine how many days it is from today until your next birthday 4. Write a program that displays the current date in this format Today is August 1, 2003 It is the 1st day of August Today is Fridayarrow_forwardTrue or False ___ 20. The statement System.out.println(“\\\\\t\\\\”); will print the result: \\\\. ___ 21. Stepwise refinement technique should be used when you start learning how to write a Java program. ___ 22. Java comment symbols /* and */ can be nested in a Java program. ___ 23. Program header is important and should be included in every Java program you write. ___ 24. Java has a set of reserved words that cannot be used as identifiers. ___ 25. Double is a legitimate identifier.arrow_forwardName:- MIT Note:- Please type this java code and also need an output for this given Java program. =>Also this is a whole one question. So please read carefully and then type the correct java code.arrow_forward
- NB: This question shouldn't get rejected at any cost everything is clear please help me answer it, the reason i pay is to get this type of questions answered, take 3-6 hours to answer it CASE STUDY: A PAYROLL SYSTEM use Java to develop a payroll software to assist in paying the salary of employee/staff of a certain university named XYZ University. Assume we have three employees in the university with ranks - Programmer, Admin and Librarian, write a Java program to calculate and printout the total salary of these three employees in the institution. The program should have the following features:1) Create a public class named: Employee that would get the firstname and lastname of each employee from the keyboard/user2) Create three objects: prog, adm and lib, for programmer, admin and librarian respectively to access the properties in Employee class.3) Create EmployeeSalary as parent interface to store basic_sal, housing_all and transport_all. The values for these three items are fixed…arrow_forwardwrite the codes in java Last month Joe purchased some stock in Acme Software, Inc. Here are the details of thepurchase:• The number of shares that Joe purchased was 1,000.• When Joe purchased the stock, he paid $32.87 per share.• Joe paid his stockbroker a commission that amounted to 2% of the amount he paidfor the stock.Two weeks later Joe sold the stock. Here are the details of the sale:• The number of shares that Joe sold was 1,000.• He sold the stock for $33.92 per share.• He paid his stockbroker another commission that amounted to 2% of the amount hereceived for the stock.Write a program that displays the following information:• The amount of money Joe paid for the stock. • The amount of commission Joe paid his broker when he bought the stock. • The amount that Joe sold the stock for. • The amount of commission Joe paid his broker when he sold the stock. • Display the amount of profit that Joe made after selling his stock and paying the twocommissions to his broker. (If the amount…arrow_forwardPlease help me write a tic tac toe game using java. Please put graphics, a 8x8 grid, a score board, music, a user can verse the computer or someone their friend(button), and please put music. Thank you. For the 8x8 grid the user must make a row of 8 rows horizontally, vertically, and diagonally to win. An write the steps of the program. Requirements are belowarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT