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
levacccp [35]
4 years ago
10

I need help with this assignment

Computers and Technology
1 answer:
Yuki888 [10]4 years ago
3 0

Answer:

import java.util.Scanner;

public class CalculatingSales {

  public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);

      int product, quantity;

      double total = 0;

      while(true) {

          System.out.println("Enter product_id and quantity(0 0 to stop): ");

          product = sc.nextInt();

          quantity = sc.nextInt();

          if(product==0 && quantity == 0)  

              break;

          switch (product) {

          case 1:

              total = total + 2.98*quantity;

              break;

          case 2:

              total = total + 4.50*quantity;

              break;

          case 3:

              total = total + 9.98*quantity;

              break;

          case 4:

              total = total + 4.49*quantity;

              break;

          case 5:

              total = total + 6.87*quantity;

              break;

          default:

              System.out.println("Invalid option");

          }

      }

      System.out.println("total value: "+total);

      sc.close();

  }

}

Explanation:

  • Take the product and quantity as input from user.
  • Use a switch statement to multiply the total with their relevant value.  
  • Display the total value.
You might be interested in
Find the number of ideal integers within the given segment [low,high] inclusive. An ideal number is a positive integer that has
Alex Ar [27]

Answer:

  1. low = 10
  2. high = 50
  3. count = 0
  4. for i in range(low, high + 1):
  5.    if(i % 3 == 0 and i % 5 == 0):
  6.        count += 1
  7. print(count)

Explanation:

The solution code is written in Python.

We can create low and high variables to store the lower bound and upper bound in the range (Line 1-2)

Next create a counter variable, count (Line 3).

Use a for loop to traverse through the number between lower bound and upper bound and check if the current number-i is divisible by 3 and by 5, increment the count by one.

After the loop, print the count and we can get the number of ideal integers within the range (Line 8).

6 0
4 years ago
Which of the following is the last step in creating a budget?
sweet [91]
You answer to the question is C
3 0
3 years ago
What happens if you move unencrypted files into an encrypted folder?
mr_godi [17]
The new files become encrypted
6 0
3 years ago
Which of the following is NOT a type of cable used in wired networks?a) Unshielded coaxialb) Coaxialc) Unshielded twisted-paird)
zysi [14]

Answer:

I think it is unshielded coaxial. Not 100% sure.

Explanation:

5 0
4 years ago
Print person1's kids, call the incNumKids() method, and print again, outputting text as below. End each line with a newline.
Brilliant_brown [7]

Answer:

Explanation:

The following code was written in Java and modifies the code so that for the given input such as 3 it outputs the exact information shown in the sample output.

import java.util.Scanner;

class CallPersonInfo {

   public static void main(String [] args) {

       Scanner scnr = new Scanner(System.in);

       PersonInfo person1 = new PersonInfo();

       int personsKid;

       System.out.println("How many kids do you have:");

       personsKid = scnr.nextInt();

       person1.setNumKids(personsKid);

       /* Your solution goes here */

       System.out.println("Kids: " + person1.getNumKids());

       person1.incNumKids();

       System.out.println("New Baby, kids now: " + person1.getNumKids());

   }

}

class PersonInfo {

   private int numKids;

   public void setNumKids(int setPersonsKids) {

       numKids = setPersonsKids;

   }

   public void incNumKids() {

       numKids = numKids + 1;

   }

   public int getNumKids() {

       return numKids;

   }

}

4 0
3 years ago
Other questions:
  • Think of a game you are familiar with and identify at least three team responsibilities which were required to make the game, on
    5·1 answer
  • The _________ contains approximately 200 million axons.
    13·2 answers
  • Which network component connects a device with the transmission media?
    9·1 answer
  • Speed is how fast an object moves a certain distance within a length of time. How is speed calculated?
    14·2 answers
  • Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar co
    12·1 answer
  • Good ways to increase sales on phone accesories?
    10·2 answers
  • What will be the code in CSS, to set
    13·1 answer
  • What are two advantages of a pay-for-use online conferencing service compared to a free service? (Choose two)
    5·1 answer
  • Select the best answer from the drop-down menu.
    14·2 answers
  • 2
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!