Question: java 4 . 1 0 Compare and contrast the if single - selection statement and the while iteration statement. How are these two statements similar?
java
Compare and contrast the if singleselection statement and the while iteration statement. How are these two statements similar? How are they different?
Explain what happens when a Java program attempts to divide one integer by another. What happens to the fractional part of the calculation? How can you avoid that outcome?
Describe the two ways in which control statements can be combined.
What type of iteration would be appropriate for calculating the sum of the first positive integers? What type would be appropriate for calculating the sum of an arbitrary number of positive integers? Briefly describe how each of these tasks could be performed.
What is the difference between preincrementing and postincrementing a variable?
Identify and correct the errors in each of the following pieces of code. Note: There may be more than one error in each piece of code.
int x total;
while x
total x;
x;
while x
total x;
x;
while y a
System.out.printlny;
y;
What does the following program print?
Exercise : Mystery.java
public class Mystery
public static void mainString args
int x ;
int total ;
while x
int y x x;
System.out.printlny;
total y;
x;
System.out.printfTotal is dn total;
For Exercise through Exercise perform each of the following steps:
Read the problem statement.
Formulate the algorithm using pseudocode and topdown, stepwise refinement.
Write a Java program.
Test, debug and execute the Java program.
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 floatingpoint results. Use class Scanner and sentinelcontrolled iteration to obtain the data from the user.
Credit Limit Calculator Develop a Java application that determines whether any of several departmentstore 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".
Sales Commission Calculator A large company pays its salespeople on a commission basis. The salespeople receive $ per week plus of their gross sales for that week. For example, a salesperson who sells $ worth of merchandise in a week receives $ plus of $ or a total of $ Youve been supplied with a list of the items sold by each salesperson. The values of these items are shown in Fig. 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.
Item Value
Item values for Exercise
Salary Calculator Develop a Java application that determines the gross pay for each of three employees. The company pays straight time for the first hours worked by each employee and time and a half for all hours worked in excess of 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.
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 integers and determines and prints the largest integer. Your program should use at least the following three variables:
counter:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
