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]
4 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]4 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
Explain on what you did and give on how problems as such can be avoid inthe future
iragen [17]
More info please, it is very invalid
8 0
3 years ago
Who is considered as the father of computer science​
Andru [333]

Answer:

Turing is considered as the father of computer science

4 0
3 years ago
Read 2 more answers
A programmer has an idea to use just one language for the content, structure, and style of web pages. What might be a problem wi
Juliette [100K]
Doesn’t give the programmer a lot of freedom to be creative. Using only one language on the web limits the amount features the programmer could create.

For example, just only using HTML limits the web page’s features to use scripts like Javascripts.
8 0
3 years ago
Assume that x and y are boolean variables and have been properly initialized. !(x || y) || (x || y) The result of evaluating the
LenaWriter [7]

Answer:

The answer is "Always true "

Explanation:

Following are the program to this question:

#include <iostream>//header file

using namespace std;

int main()//main method

{

bool x=true;//defining bool variable x and assign value

bool y=false;//defining bool variable y and assign value

if(!(x || y) || (x || y))//use given condition with if block

{

   cout<<"True";//print true message

}

else//defining else block

{

   cout<<"false";//print false message

}

   return 0;

}

In the above code two bool variable is declared, that hold ture and false, and used in the given expression with the condition statement, that checks the given value. In the code the logical gate OR gate that always print the true value.

3 0
3 years ago
E sentences about logic problems using the drop-down menu. Logic problems can be solved with . Logic problems can be solved in a
egoroff_w [7]

Answer:

Logic problems can be solved with WELL-DEFINED STEPS. Logic problems can be solved in a METHODICAL MANNER. The WELL-DEFINED STEPS  to solve a logic problem form an algorithm.  Algorithms enable a  COMPUTER to solve logic problems. Please, if you could, mark brainiest and thank. Thank you!

4 0
3 years ago
Other questions:
  • In what country did true printing first take place?
    12·2 answers
  • What is the name of small programs stored on the hard drive that tell the computer how to communicate with a specific hardware d
    5·1 answer
  • Luis is cloud-based( microsoft bot framework). true false
    13·2 answers
  • When you use cloud computing, what do you need to access your files and applications?
    12·1 answer
  • Please Help!! How to code this in Python?
    11·1 answer
  • What is the value of i printed? j = i = 1 i += j + j * 5 print("What is i?", i)
    11·1 answer
  • Complete the sentence.
    6·1 answer
  • On an XBOX 360, what does it mean if you get 4 red rings on your console?
    5·1 answer
  • How many bits would be needed to count all of the students in class today? There are 40 students.
    10·1 answer
  • I will make you brainless just answer all this question!!​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!