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
Illusion [34]
3 years ago
11

Write a function "cashier" that receives an int "c" for the number of items bought. The function will ask the price and task rat

e of each item and prints out the total cost. Sample Input Expected Output For item 1 Enter the price: 10 Enter the tax rate: 0 For item 2 Enter the price: 20 Enter the tax rate: 8 Your total price is 31.6 Sample Input 2 Expected Output 2 For item 1 Enter the price: 100 CS103 -Lab 5 Page 3 of S Enter the tax rate:8 For item 2 Enter the price: 20 Enter the tax rate: 0 For item 3 Enter the price1 40 Enter the tax rate:8 Your total price is 171.2 3406
Computers and Technology
1 answer:
Ganezh [65]3 years ago
4 0

Answer:

   public static double cashier(int c){

       double totalCost = 0.0;

       for(int i = 0; i<c; i++){

           System.out.println("Enter the price for the "+(i+1)+" item");

           Scanner in = new Scanner(System.in);

           double price = in.nextDouble();

           System.out.println("Enter the tax for the "+(i+1)+" item");

           double taxRate = in.nextDouble();

           double tax = (taxRate/100)*price;

           totalCost = totalCost+(price+tax);

       }

       return totalCost;

   }

Explanation:

Find the complete java code that prompts user for number of items below:

import java.util.Scanner;

public class VendingTest {

   public static void main(String[] args) {

       System.out.println("How many Items did you buy");

       Scanner input = new Scanner(System.in);

       int c = input.nextInt();

       //Calling the method cashier()

       double returnedTotal = cashier(c);

       System.out.println("Total price: "+returnedTotal);

   }

   public static double cashier(int c){

       double totalCost = 0.0;

       for(int i = 0; i<c; i++){

           System.out.println("Enter the price for the "+(i+1)+" item");

           Scanner in = new Scanner(System.in);

           double price = in.nextDouble();

           System.out.println("Enter the tax for the "+(i+1)+" item");

           double taxRate = in.nextDouble();

           double tax = (taxRate/100)*price;

           totalCost = totalCost+(price+tax);

       }

       return totalCost;

   }

}

You might be interested in
During early recording, microphones picked up sound waves and turned them into electrical signals that carved a _______ into the
Tcecarenko [31]

Answer:

Groove

Explanation:

There is not much to explain

8 0
3 years ago
What is green computing in non-technical term?​
DochEvi [55]

Answer:

Green computing is also known as green information technology (green IT)

4 0
3 years ago
Which of the following correctly revises the passive voice of the sentence above to active voice?
muminat

There is no question on the passive voice, therefore I cannot change it to an active voice.

I hope this helped!

6 0
3 years ago
The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop
shtirl [24]

Answer:

False

Explanation:

for loop is used to run the statement again and again until the condition put inside the for loop is false.

syntax:

for(initialization;condition;increment/decrement)

{

  statement;

}

the initialization scope is valid only within the curly braces of the for loop. it is not valid outside the body of the for loop.

because initialization is the part of the for loop.

4 0
3 years ago
A web designer should test each link to make sure it is not _______ for the best user experience. This is known as __________ te
Likurg_2 [28]

Answer:

Explanation:

it

computer

6 0
3 years ago
Read 2 more answers
Other questions:
  • The qwerty keyboard is the most common layout of keys on a keyboard.
    5·2 answers
  • True or false? any webb app can be accessed and run on any computing
    12·1 answer
  • What is the different between a computer and a phone?​
    15·1 answer
  • Match each item with a statement below. a.Authentication b.Brute force attack c.Dictionary attack d.Password e.Shoulder surfing
    13·1 answer
  • You are the IT security manager for a retail merchant organization that is just going online with an e-commerce website. You are
    14·1 answer
  • What would be the result of running the command chown :root file1.txt
    14·1 answer
  • Question :
    6·1 answer
  • Who is the first British in Europe ​
    10·1 answer
  • Read the scenario and then choose which type of
    12·2 answers
  • Select the correct answer.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!