Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PetstoreCalculator
- {
- public static void main(String[] args){
- int option;
- boolean check = false;
- Scanner input = new Scanner(System.in);
- option = 0;
- double total,storetax;
- storetax = 1.05;
- do{
- System.out.println("What pet would you like to purchase: ");
- System.out.println("1. Snakes");
- System.out.println("2. Turtles");
- System.out.println("3. Geckos");
- System.out.println("4. Iguanas ");
- System.out.println("Enter Choice: ");
- option = input.nextInt();
- total = 0;
- if (option == 1){
- System.out.println("25");
- total = 25 * storetax;
- System.out.println("The total cost is: $" +total);
- System.exit(0);
- }
- else if (option == 2){
- System.out.println("$20");
- total = 20 * storetax;
- System.out.println("The total cost is: $" +total );
- System.exit(0);
- }
- else if (option == 3){
- System.out.println("$35");
- total = 35 * storetax;
- System.out.println("The total cost is: $" +total );
- System.exit(0);
- }
- else if (option == 4){
- System.out.println("$45");
- total = 45 * storetax;
- System.out.println("The total cost is: $" +total );
- System.exit(0);
- }
- else if (option == 0){
- System.out.println("Thank you!");
- System.exit(0);
- }
- else{
- System.out.println("Error, entered wrong number.");
- }
- goodbye();
- while (!check);
- }while (option >= 5);
- } //end main
- private static void goodbye() {
- String goodbye = "\n ***Good Bye, Have a Nice Day***";
- System.out.println( goodbye );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement