When you go out to eat, you always tip 20% of the bill amount. But who’s got the time to calculate the right tip amount every time? Not you that’s for sure! You’re making a program to calculate tips and save some time. Your program needs to take the bill amount as input and output the tip as a float. Sample Input 50 Sample Output 10.0
Answers
Answer:
Java:
import java.util.Scanner
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter bill amount: ");
int bill = scanner.nextInt();
float tip = (float) 20/100 * bill;
System.out.println("The tip amount is " + tip);
}
}
Python:
bill = int(input("Enter bill amount: "))
tip = 20/100 * bill
print("The tip amount is ",float(tip))
Answer:
Python program for given question.
Explanation:
From the above question,
They have given :
When you go out to eat, you always tip 20% of the bill amount. But who’s got the time to calculate the right tip amount every time? Not you that’s for sure! You’re making a program to calculate tips and save some time. Your program needs to take the bill amount as input and output the tip as a float.
Declare 2 variables example a, b
Take the total bill amount from the user n store it in a
Find the percentage 0.2*a and store in b
Print b
PROGRAM
bill = int(input())
x = 20
y = 100
tip = (bill * int (x) / int (y) )
print(float(tip))
For more such related questions : https://brainly.in/question/17412895
#SPJ3