1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Otrada [13]
3 years ago
7

Write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of un

its sold (this is two separate prompts for input values). You must use a switch statement and a sentinel-controlled loop (i.e. a loop that stops execution when an out of range value, such as -1, is input). All 15 items below are for a single purchase. There are five sets of inputs as follows:
Computers and Technology
1 answer:
Dovator [93]3 years ago
5 0

Answer:

Follows are the code to the given question:

import java.util.*;//import package for input  

public class Main//defining a class Main  

{

public static void main(String[] arp)//defining main method  

  {

   double total=0,sub_Total=0;//defining double variable

   int Units,product_Num;//defining integer variable

   Scanner obq = new Scanner(System.in);//creating Scanner class object for input value

   System.out.print("Product: ");//print message

   product_Num=obq.nextInt();//input value

   while(product_Num>=1 && product_Num<=5)//defining loop for input value

   {

       sub_Total=0;//assign value 0 in sub_Total

       switch(product_Num)//use switch for check condition

          {

          case 1://for case 1

              {

              System.out.print("Enter No of units :");//print message

              Units=obq.nextInt();//input value

              sub_Total=Units*2.98;//calculating sub_Total value

              total+=sub_Total;//add value in total variable

              System.out.printf("Sub Total :$%.2f\n",sub_Total);//print value

          break;//use break keyword

          }

          case 2://for case 2

              {

              System.out.print("Enter No of units :");//print message

              Units=obq.nextInt();//input value

              sub_Total=Units*4.50;//calculating sub_Total value

              total+=sub_Total;//add value in total variable

              System.out.printf("Sub Total :$%.2f\n",sub_Total);//print value

          break;//use break keyword

          }

          case 3://for case 3

              {

              System.out.print("Enter No of units :");//print message

              Units=obq.nextInt();//input value

              sub_Total=Units*9.98;//calculating sub_Total value

              total+=sub_Total;//add value in total variable

              System.out.printf("Sub Total :$%.2f\n",sub_Total);//print value

          break;//use break keyword

          }

          case 4://for case 4

              {

              System.out.print("Enter No of units :");//print message

              Units=obq.nextInt();//input value

              sub_Total=Units*4.49;//calculating sub_Total value

              total+=sub_Total;//add value in total variable

              System.out.printf("Sub Total :$%.2f\n",sub_Total);//print value

          break;//use break keyword

          }

        case 5://for case 5

              {

              System.out.print("Enter No of units :");//print message

              Units=obq.nextInt();//input value

              sub_Total=Units*6.87;//calculating sub_Total value

              total+=sub_Total;//add value in total variable

              System.out.printf("Sub Total :$%.2f\n",sub_Total);//print value

          break;//use break keyword

          }

       }

  System.out.print("Product: ");//print message  

  product_Num=obq.nextInt();//input value

      }

      System.out.printf("\nOvertoal Total :$%.2f\n",total);//print total value

  }

}

Output:

Product: 1

Enter No of units :1

Sub Total :$2.98

Product: 2

Enter No of units :2

Sub Total :$9.00

Product: 3

Enter No of units :3

Sub Total :$29.94

Product: 4

Enter No of units :4

Sub Total :$17.96

Product: 5

Enter No of units :5

Sub Total :$34.35

Product: -1

Overtoal Total :$94.23

Explanation:

In this program, two double variables "total,sub_Total" and two integers "Units,product_Num" is used, in the next step,  the scanner class is used for an input value, for this, a while loop is defined that uses the switch for input value and calculate  its respective value, and use the print method to print its value.

You might be interested in
Project using simple formulas
Mrac [35]
Please explain more
7 0
3 years ago
Case Study
larisa [96]

Answer:

1. Design system to avoid theatre tickets selling issue.

2. Resources provided to student who can built a system for the theatre tickets booking.

3. Medallion Theatre Booking System

Add/edit patron

Add/edit production

Add/edit performance

Add/edit seats

Purchase tickets

Generate Tickets Sold Report

4.GUI or graphical user interface allows the user to connect through graphical icons.

Explanation:

The main purpose is to avoid problems of duplicate tickets sales in future. The system will enable the selling of each seat to one customer only and when an attempt is made to resold the seat the system warns the user creating a check for original sale. This will help theatre to avoid any issues in future and customers will be happy with their ease of confirmation of booking.

7 0
3 years ago
Factoring of integers. Write a python program that asks the user for an integer and then prints out all its factors. For example
Oduvanchick [21]

num = int(input("Enter a number: "))

i = 2

while num > 1:

   if num % i == 0:

       num = num / i

       print(i, end=" ")

       i = 2

   i += 1

I hope this helps!

8 0
3 years ago
1. Encrypt this binary string into cipher text: 110000. Include in your answer the formula the
puteri [66]

Answer:

Encrypt this binary string into ciphertext: 110000. Include

in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x N mod (m) = Y

-Decrypt this ciphertext into a binary string: 106

Now that you can see how public and private keys work in a real-world scenario, please explains how it works for computers and internet communications in relation to cybersecurity.

Explanation: ……………..

6 0
2 years ago
Pls help is very urgent and I will mark u as brainliest plsssss​
elena-s [515]

Answer:

this is the method of processing wood

5 0
3 years ago
Read 2 more answers
Other questions:
  • What are the benefits of organizing your thoughts before you begin your speech
    14·1 answer
  • What component of a computer system holds the operating system when the computer is not running
    6·2 answers
  • All of the nested folders you created will carry the same permissions as the __________ until you make changes.
    10·1 answer
  • Write a paper, 2-3 paragraphs that discuss how to defend ideas objectively through effective communication. Include the skills n
    6·1 answer
  • Program 4: But I haven’t taken Calculus yet! OK – we admit, this one might look nasty, but read on because it’s not that bad. On
    11·1 answer
  • Assume you have a int variable n that has already been declared and initialized. Its value is the number of integers that need t
    13·1 answer
  • A website's ____ page provides basic information about the individual or organization and includes a navigation bar with links t
    13·1 answer
  • Discuss how printing, publishing, and e-learning industries have transformed on evolved due to developments and advances the fie
    14·1 answer
  • Your organization has 20 employees who need an accounting software update installed. Due to a miscommunication, the purchaser on
    6·1 answer
  • How to create create a database in mysql using clv files
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!