A controlled transaction solution for Joe's Pizza, your friendly neighborhood pizza shop. Joe only make $200 worth of pizza everyday. Modify your program so that if the running total will exceed $200, print a warning and DO NOT add this value to running total. Instead, go to the beginning of loop statement block and wait for next transaction.   can you please write it in import java.util.Scanner;  and can you make it so i can copy and past it. thank you in advance the code from before  /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package personal;import java.util.Scanner;/** * * @author Mabda */public class Personal {     /**     * @param args the command line arguments     */    public static void main(String[] args) {         int num, sum = 0;        char choice;        Scanner key = new Scanner(System.in);        while (true) {            System.out.print("\nEnter sale amount: ");            num = key.nextInt();            sum += num;            if(sum>100)            {                System.out.print("\nTotal sum exceeds more than 100.\n");            }            System.out.print("Do you want to continue..: ");            choice = key.next().charAt(0);            if (choice == 'n')             {                System.out.print("\nToday's sum of all sales: " + sum + "\n\n");                break;            }        }    }    }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

A controlled transaction solution for Joe's Pizza, your friendly neighborhood pizza shop.

Joe only make $200 worth of pizza everyday. Modify your program so that if the running total will exceed $200, print a warning and DO NOT add this value to running total. Instead, go to the beginning of loop statement block and wait for next transaction.

 

can you please write it in import java.util.Scanner; 

and can you make it so i can copy and past it. thank you in advance

the code from before 

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package personal;import java.util.Scanner;/** * * @author Mabda */public class Personal {
    /**     * @param args the command line arguments     */    public static void main(String[] args) {         int num, sum = 0;        char choice;        Scanner key = new Scanner(System.in);        while (true) {            System.out.print("\nEnter sale amount: ");            num = key.nextInt();            sum += num;            if(sum>100)            {                System.out.print("\nTotal sum exceeds more than 100.\n");            }            System.out.print("Do you want to continue..: ");            choice = key.next().charAt(0);            if (choice == 'n')             {                System.out.print("\nToday's sum of all sales: " + sum + "\n\n");                break;            }        }    }    }

Expert Solution
program

import java.util.Scanner;
public class Main
{
 public static void main(String[] args) {
  int sum=0,num;
  char choice;
  Scanner key=new Scanner(System.in);
  while(true)
  {
  System.out.println("Enter sales amount:");
  num = key.nextInt(); //to read sales amount
  sum+=num;//to store sales amount
  //condition for checking total sales more than 200 or not 
  if(sum>200)
  {
      System.out.println("Total sales exceeds more than 200");
      sum-=num;// if total sales exceeds 200 for the transaction to minus present transaction 
  }
  System.out.println("Do you want to continue(y/n):");
  choice = key.next().charAt(0);//to read character to continue or stop program 
  if(choice=='n')
  {
      System.out.println("Today total sum of sales is:"+sum);
      break;//to break the loop if user enters n
  }
  else
  {
      continue;//to continue to next transaction if user enters y
  }
  }
 }
}

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education