Tip/tax calculator

/** * This program gives tips and distributes among clients * Author: Peter.T * created: 9/18/2017 */ import java.util.*; public class Tips //first letter of class name should be capitalized { public static void main(String[] args) { int num; boolean why = true; while(why){ Scanner scan = new Scanner(System.in); System.out.println("Please enter the value of the bill (disregard the $ sign)."); double bill = scan.nextInt(); System.out.println("How much doth thee want to tip (type 0 if you're a cruel person)?"); double ptip = scan.nextInt(); double tip = bill * (ptip/100); double tipbill = tip+bill; System.out.println("Tip: "+tip); System.out.println("Bill with tip: "+tipbill); System.out.println("Please enter the percentage of tax, if any. If not then enter 0."); double tax = scan.nextInt(); double taxation = bill * (tax/100); double totalbill = tipbill+taxation; System.out.println("Taxation: "+tax); System.out.println("Final bill: "+totalbill); System.out.println("How many people doth thou want to spread thy cost?"); //I used double for the next variable so if someone has half a person it will work. double people = scan.nextInt();//you never know ;D double splitbill = totalbill/people; System.out.println("Split bill: "+splitbill); System.out.println("Now, Have a nice evening, thanks for using me ;D"); System.out.println("do you want to use another price? type 1 to play again and 2 to quit"); num = scan.nextInt(); if(num==2){ why = false; } } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.