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
Delicious77 [7]
3 years ago
15

Write a Python function that takes as input parameters base_cost (a float) and customer_type and prints a message with informati

on about the total amount owed and how much the tip was. You may recognize this program from HW1. We'll write a very similar program, just modifying it and using string formatting. Feel free to copy/paste code from before and modify it. As a reminder, the tip amounts are 10%, 15% and 20% for stingy, regular, and generous customers. And the tax amount should be 7%. The total amount is calculated as the sum of two amounts: check_amount = base_cost*1.07 tip_amount = tip_percentage*check_amount To receive full credit, you must use string formatting to print out the result from your function, and your amounts owed should display only 2 decimal places (as in the examples below). To "pretty print" the float to a desired precision, you will need to use this format operator (refer back to class slides for more explanation): %.2f Print the results to the console like in the example below, including the base cost of the meal, tax, three tip levels, and total for regular customers. Test cases: inputs: check_amount = 20, customer_type = "regular" --> output: Total owed by regular customer = $24.61 (with $3.21 tip) inputs: check_amount = 26.99, customer_type = "generous" --> output: Total owed by generous customer = $34.66 (with $5.78 tip) inputs: check_amount = 26.99, customer_type = "generous" --> output: Total owed by stingy customer = $16.83 (with $1.53 tip)

Computers and Technology
1 answer:
PSYCHO15rus [73]3 years ago
8 0

Answer:

Explanation:

Thanks for the question, here is the code in python

The 3rd example given in question is incorrect

inputs: check_amount = 26.99, customer_type = "generous" --> output: Total owed by stingy customer = $16.83 (with $1.53 tip)

the customer type in the above passed is generous but why the output is showing for stingy, I think this is incorrect

Here is the function, I have given explanatory names so that you can follow the code precisely and also used pretty formatting.

thank you !

===================================================================

def print_tip(base_cost, customer_type):

   TAX_PERCENTAGE = 1.07

   STINGY_PERCENTAGE = 0.1

   REGULAR_PERCENTAGE = 0.15

   GENEROUS_PERCENTAGE = 0.20

   check_amount = base_cost * TAX_PERCENTAGE

   tip_amount = 0.0

   if customer_type == 'regular':

       tip_amount = check_amount * REGULAR_PERCENTAGE

   elif customer_type == 'generous':

       tip_amount = check_amount * GENEROUS_PERCENTAGE

   elif customer_type == 'stingy':

       tip_amount = base_cost * STINGY_PERCENTAGE

   total_amount = tip_amount + check_amount

   print('Total owed by {} customer = ${} (with ${} tip)'.format(customer_type, '%.2f' % total_amount,'%.2f' % tip_amount))

print_tip(20, 'regular')

print_tip(26.99, 'generous')

print_tip(14.99, 'stingy')

You might be interested in
Naynar kis dhrm se sambandhit hai​
Inessa05 [86]

Answer:

Islam dharm se sabandhit

5 0
3 years ago
Read 2 more answers
A software program installed without the user's knowledge and designed to alter the way a computer operates or to cause harm to
RSB [31]

Answer:

The correct answer for the given question is "Computer virus"

Explanation:

A computer virus is a software program that is installed automatically without user's knowledge and designed to duplicate itself .The main purpose of computer virus is to harm the computer system.

Some of the points regarding computer virus

1.The computer virus contain malicious software Which harm the computer system.

2.It damage the  computer computer system in such away that sometimes users will unable to access some certain functionality of computer system.

5 0
3 years ago
1
max2010maxim [7]

Answer:Go to the location where you want to save the file.

Explanation:

8 0
4 years ago
Write a recursive function to determine if a number is prime.
Darya [45]

Answer:

Follows are the code to find the prime number:

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

public class Main//defining a class

{  

public static boolean Prime(int x, int j)//defining a method isPrime    

   {  

       if (x<= 2) //use if block to check x less than equal to 2

           return (x== 2) ? true : false; //use bitwise operator to return value  

       if (x%j == 0) //use if to check x%j equal to 0

           return false;//return false value  

       if (j*j > x)//defining if that check i square value greater than n  

           return true; //return true value

       return Prime(x, j+1); //callling recursive method

   }  

   public static void main(String[] as)//main method  

   {  

       int n; //defining integer variable

       Scanner oxc=new Scanner(System.in);//creating Scanner class object

       n=oxc.nextInt();//input value

       if (Prime(n, 2))  //use if block to call isPrime method

           System.out.println("Yes"); //print value  

       else //else block

           System.out.println("No");  //print value  

   }  

}  

Output:

5

Yes

Explanation:

In this code, a static boolean method "Prime" is declared, that accepts two integer variables in its parameter and defines the if block that checks the prime number condition by the recursive method and returns a value true or false. Inside, the main method an integer variable is declared that uses the Scanner class object for input value and passes into the method and prints its value.

6 0
3 years ago
Designing a video game takes tons of creativity. What inspires your personal creativity and ideas for video games? Explain and g
Whitepunk [10]

Answer:

This is what I have so far

Designing a video game takes tons of creativity. What inspires your personal creativity and ideas for video games? Explain and give several specific examples. How do you make sure your ideas are original and not copied directly from other video games? Explain.

What inspires my personal creativity is all the indie games I have played in the past, and they have always amazed me with their design, video games have always been a part of me from the Mario games I played when I was little to AAA titles. My ideas are original because I’ve seen so much, that I know when something is unique and original.

Explain how the four-game mechanics mentioned in the unit (reward, risk/loss, levels, and feedback) could work together to create an interesting sports video game.

Every 10 levels is a new sport and each level is harder, but at the end of each level you earn money to buy better gear, (like a system from simple rpg,) but if you lose, you also lose money. Also, you would need to use feedback that you would get from players to improve the game.

You’ve learned that video games use rewards to keep players coming back for more. Can you think of an example in real life that uses rewards to keep people coming back for more? How is this similar to video game rewards? Explain.

When a person works 1 job for many years, they may get burnt out, but if they get a raise or a promotion every once and awhile, then they will be more motivated and come back for more. This is similar to games in a few ways, like if you play a single game for years, it will get boring, but if that game receives an update, then it will motivate people to play.

7 0
3 years ago
Other questions:
  • Coretta is thinking about which careers she would enjoy. She considers her personal skills and interests. She enjoys reading and
    13·2 answers
  • Which one is it A,B,C,D
    10·2 answers
  • PLZ HELP ME!!!
    13·1 answer
  • What is the standard markup language of the world wide web?
    14·1 answer
  • Are Most job applications are online
    9·1 answer
  • Identify a true statement of a JavaScript program in a web form.
    10·1 answer
  • Write a recursive function using pseudocode or C/C++.
    8·1 answer
  • If you decide you want to meet someone you met online, what should you do first? A. Tell your best friend. B. Call the person yo
    12·1 answer
  • How many times will an infinite loop repeat?
    9·1 answer
  • What is the introduction of an algorithm and programming and how does it work?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!