Question: in java 4 . 1 7 ( Gas Mileage ) Drivers are concerned with the mileage their automobiles get. One driver has kept track of

in java4.17(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.
4.18(Credit Limit Calculator) Develop a Java application that determines whether any of several department-store customers has exceeded the credit limit on a charge account. For each customer, the following facts are available:
account number
balance at the beginning of the month
total of all items charged by the customer this month
total of all credits applied to the customers account this month
allowed credit limit.
The program should input all these facts as integers, calculate the new balance (= beginning balance + charges credits), display the new balance and determine whether the new balance exceeds the customers credit limit. For those customers whose credit limit is exceeded, the program should display the message "Credit limit exceeded".
4.19(Sales Commission Calculator) A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5,000 worth of merchandise in a week receives $200 plus 9% of $5,000, or a total of $650. Youve been supplied with a list of the items sold by each salesperson. The values of these items are shown in Fig. 4.33. Develop a Java application that inputs one salespersons items sold for last week and calculates and displays that salespersons earnings. Theres no limit to the number of items that can be sold.
Fig. 4.33
Item Value
1239.99
2129.75
399.95
4350.89
Item values for Exercise 4.19.
4.20(Salary Calculator) Develop a Java application that determines the gross pay for each of three employees. The company pays straight time for the first 40 hours worked by each employee and time and a half for all hours worked in excess of 40. Youre given a list of the employees, their number of hours worked last week and their hourly rates. Your program should input this information for each employee, then determine and display the employees gross pay. Use class Scanner to input the data.
4.21(Find the Largest Number) The process of finding the largest value is used frequently in computer applications. For example, a program that determines the winner of a sales contest would input the number of units sold by each salesperson. The salesperson who sells the most units wins the contest. Write a pseudocode program, then a Java application that inputs a series of 10 integers and determines and prints the largest integer. Your program should use at least the following three variables:
counter: A counter to count to 10(i.e., to keep track of how many numbers have been input and to determine when all 10 numbers have been processed).
number: The integer most recently input by the user.
largest: The largest number found so far.
4.22(Tabular Output) Write a Java application that uses looping to print the following table of values:
N 10*N 100*N 1000*N
1101001000
2202002000
3303003000
4404004000
5505005000
4.23(Find the Two Largest Numbers) Using an approach similar to that for Exercise 4.21, find the two largest values of the 10 values entered. [Note: You may input each number only once.]
4.24(Validating User Input) Modify the program in Fig. 4.12 to validate its inputs. For any input, if the value entered is other than 1 or 2, keep looping until the user enters a correct value.
4.25 What does the following program print?
1// Exercise 4.25: Mystery2.java
2 public class Mystery2{
3 public static void main(String[] args){
4 int count =1;
5
6 while (count <=10){
7 System.out.println(count %2==1?"****" : "++++++++");
8++count;
9}
10}
11}
4.26 What does the following program print?
1// Exercise 4.26: Mystery3.java
2 public class Mystery3{
3 public static void main(String[] args){
4 int row =10;
5
6 while (row >=1){
7 int column =1;
8
9 while (column <=10){
10 System.out.print(row %2==1?"<" : ">");
11++column;
12}
13
14--row;
15 System.out.println();
16}
17}
18}
4.27(Dangling-else Problem) The Java compiler always associates an else with the immediately

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!