
TipCalculator1
By: a guest on
Dec 12th, 2012 | syntax:
Java | size: 1.27 KB | hits: 136 | expires: Never
/*
This program will use a bill and service rating
to compute the tip and total amount as well as
divide the entire cost by the number of people
in one's party.
*/
import java.util.Scanner;
public class TipCalculator1 {
public static void main(String[] args) {
//Create a scanner
Scanner input = new Scanner(System.in);
//Obtain the total bill amount
System.out.println("Enter bill amount. eg. 37.96: ");
double totalBill = input.nextDouble();
//Obtain the service level
System.out.println("Rate the overall service from 0 to 10: ");
double serviceRating = input.nextInt();
//Obtain the number of individuals in your party
System.out.println("How many people are in your party? ");
int numberInParty = input.nextInt();
//Calculate the percentage tip
double percentageTip = ((serviceRating / 100) + 0.1);
//Calculate the total bill plus tip
double billPlusTip = totalBill + totalBill * percentageTip;
//Calculate how much each individual owes
double totalOwedByEach = billPlusTip / numberInParty;
//Print the amount owed by each person
System.out.println("With a " + (double)percentageTip + "% tip, The total bill came out to " + billPlusTip);
System.out.println("Each person owes $" + totalOwedByEach);
}
}