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
____ are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its par
Bad White [126]
<span>Truth tables are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its parts.

A truth table shows all the possible combinations (outputs) that can be produced from the given inputs. They are mainly used in Boolean algebra.</span>
4 0
3 years ago
un diagrama de flujo donde se gana una partida de ajedrez teniendo en cuenta los movimientos de la otra persona
mash [69]
Estoy tan confundido. ? estas haciendo una pregunta?

7 0
4 years ago
Create a program in Matlab that prints the numbers from 1-100.
Burka [1]

Answer:

numbers = 1:1:100;

for num=numbers

remainder3 = rem(num,3);

remainder5 = rem(num,5);

 

if remainder3==0

disp("Yee")

else

if remainder3 == 0 && remainder5 == 0

disp ("Yee-Haw")

else

if remainder5==0

disp("Haw")

else

disp("Not a multiple of 5 or 4")

end

end

end  

end

Explanation:

  • Initialize the numbers variable from 1 to 100.
  • Loop through the all the numbers and find their remainders.
  • Check if a number is multiple of 5, 3 or both and display the message accordingly.
4 0
4 years ago
What are computer engineering algorithms?
Tom [10]
An algorithm<span> is a well-defined procedure that allows a </span>computer<span> to solve a problem. Another way to describe an </span>algorithm<span> is a sequence of unambiguous instructions. ... In fact, it is difficult to think of a task performed by your </span>computer<span> that does not use</span>algorithms<span>.</span>
5 0
4 years ago
PLEASE ANSWER ASAP!!!!
kondaur [170]

Answer:

na bro, esta dificil

Explanation:

3 0
3 years ago
Other questions:
  • If you decide to get married, a trade-off would be that you have to give up being single.
    12·2 answers
  • Write a script that calculates the common factors between 8 and 24. To find a common factor, you can use the modulo operator (%)
    14·1 answer
  • When the atmosphere has too much carbon dioxide in it, the oceans absorb some of it to achieve a new balance. This is an example
    9·2 answers
  • Think about some of the most memorable and forgettable games ever created. They can be games that were
    15·1 answer
  • A) Suppose a computer has an instruction pipeline with 4 phases. How many cycles (if there are no delays) would it take to compl
    13·1 answer
  • Write a SELECT statement that returns a single value that represents the sum of the largest unpaid invoices submitted by each ve
    5·1 answer
  • What is DMTS. Explain it​
    10·2 answers
  • I have tried many times to find a gaming setup for $4k. I have tried many websites but they are not working for my liking. Any o
    15·1 answer
  • How important "saving" in every individual?​
    11·1 answer
  • You are the IT administrator for a small corporate network. The employee in Office 2 is setting up a virtualization environment
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!