*1. This program takes in user input and calculates each persons share of the cost from a trip. *2. This program uses Scanner for input/ *3. This code calculates the final cost less a discount discount.. *4. This code displays and formats the result. */ import java.util.*; public class NdunaJoyDiscuss4Wk4 { public static void main(String[] args) { String name = "Joy Nduna"; //My given name String date = "April 08, 2023";//Date code is implemented int course = 141; // The course number int section = 7382; // The section number int numDiscuss = 4; // Assignment week number // Displaying my name, course/section number, discussion week number, date System.out.println("Name: "+name+("\n")+"Class CMIS: "+course+"\n"+"Section : "+section+("\n")+"Assignment 1: Week: "+numDiscuss+("\n")+"Date: "+date); // Create a scanner object to read user input Scanner stdin = new Scanner(System.in); // Prompt for two integers separated by a space int numPeople = 0;//Set number of people to be counted double bills = 0; double billTotal = bills; int count = 0; //Initializing a constant variable final double DISCOUNT_RATE =.15; //Prompting for user input and using sentil for user control of input System.out.print("Enter you bill between $0 and $500 or 0 to exit : "); bills = stdin.nextDouble(); //While loop to control iteration while (bills != 0) { billTotal += bills; count++; numPeople++; System.out.print("Enter you bill between $0 and $500 or 0 to exit : "); bills = stdin.nextDouble(); } //Validating dauser input if (count == 0) { System.out.println("Invalid entry! : \""); } else { double eachPersonsBillShare; //Calculating the trip costs double discount = billTotal * DISCOUNT_RATE; double finalBillTotal = billTotal - discount; eachPersonsBillShare = finalBillTotal / numPeople; //Displaying the result. System.out.println(); System.out.println("The total bill for " + numPeople + " people is $ "+ billTotal + " less a discount of " + DISCOUNT_RATE + " percent."); System.out.println("The final bill for is: $ " + finalBillTotal); System.out.printf("Each person's share of the cost is $%1.2f" + " \n " , eachPersonsBillShare); } stdin.close(); } } CAN YOU ADD SOMETHING TO THIS PROGRAM AND ADD THE RESULT. THANK YOU :)
*1. This
*2. This program uses Scanner for input/
*3. This code calculates the final cost less a discount discount..
*4. This code displays and formats the result.
*/
import java.util.*;
public class NdunaJoyDiscuss4Wk4 {
public static void main(String[] args) {
String name = "Joy Nduna"; //My given name
String date = "April 08, 2023";//Date code is implemented
int course = 141; // The course number
int section = 7382; // The section number
int numDiscuss = 4; // Assignment week number
// Displaying my name, course/section number, discussion week number, date
System.out.println("Name: "+name+("\n")+"Class CMIS: "+course+"\n"+"Section : "+section+("\n")+"Assignment 1: Week: "+numDiscuss+("\n")+"Date: "+date);
// Create a scanner object to read user input
Scanner stdin = new Scanner(System.in);
// Prompt for two integers separated by a space
int numPeople = 0;//Set number of people to be counted
double bills = 0;
double billTotal = bills;
int count = 0;
//Initializing a constant variable
final double DISCOUNT_RATE =.15;
//Prompting for user input and using sentil for user control of input
System.out.print("Enter you bill between $0 and $500 or 0 to exit : ");
bills = stdin.nextDouble();
//While loop to control iteration
while (bills != 0) {
billTotal += bills;
count++;
numPeople++;
System.out.print("Enter you bill between $0 and $500 or 0 to exit : ");
bills = stdin.nextDouble();
}
//Validating dauser input
if (count == 0) {
System.out.println("Invalid entry! : \"");
}
else {
double eachPersonsBillShare;
//Calculating the trip costs
double discount = billTotal * DISCOUNT_RATE;
double finalBillTotal = billTotal - discount;
eachPersonsBillShare = finalBillTotal / numPeople;
//Displaying the result.
System.out.println();
System.out.println("The total bill for " + numPeople + " people is $ "+ billTotal + " less a discount of " + DISCOUNT_RATE + " percent.");
System.out.println("The final bill for is: $ " + finalBillTotal);
System.out.printf("Each person's share of the cost is $%1.2f"
+ " \n " , eachPersonsBillShare);
}
stdin.close();
}
}
CAN YOU ADD SOMETHING TO THIS PROGRAM AND ADD THE RESULT. THANK YOU :)
No hand written and fast answer with explanation
Step by step
Solved in 3 steps with 2 images