Can someone please help me with the tip calculator quiz | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Can someone please help me with the tip calculator quiz

No matter how I try this thing I keep getting some crazy wrong answer this is how I'm writing it bill = int(input(50)) tip = bill*0.2 print(tip) Why is this wrong can someone please explain I'm new to this and could use a little help just point me in right direction please

17th Feb 2021, 9:28 PM
Truckin Dovahkiin
Truckin Dovahkiin - avatar
14 Answers
+ 14
Then just do, bill=int(input()) tip=bill*0.2 print(tip) And it should work fine.
17th Feb 2021, 10:10 PM
Abhay
Abhay - avatar
+ 7
Abhay thanks buddy it works well ☺️
27th Apr 2021, 3:41 AM
BAVADHARANI . G
BAVADHARANI . G - avatar
+ 3
The question is asking you to create a program called "Tip Calculator" that helps calculate the tip amount you should give based on the bill amount. The tip percentage is fixed at 15% of the bill amount. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double bill = scanner.nextDouble(); double tip = bill * 0.15; // 15% of the bill System.out.println(tip); } } Here's a step-by-step explanation of this program: 1) Import the Scanner class: The program starts by importing the java.util.Scanner class. This class allows you to read user input from the console. 2) Declare and initialize variables: The program declares two variables: bill and tip. The variable bill will store the user-inputted bill amount, and the variable tip will store the calculated tip amount. 3) Read user input: The program uses the Scanner object to read a double value from the user, which represents the bill amount. It prompts the user to enter the bill amount and stores the input in the bill variable. 4) Calculate the tip: To calculate the tip amount, the program multiplies the bill amount (bill) by 0.15. This is equivalent to 15% (15/100) of the bill amount, as instructed in the question. The calculated tip amount is then stored in the tip variable. 5) Output the tip: Finally, the program prints the calculated tip amount to the console using System.out.println(). For example, if the user enters a bill amount of 124.5, the program will calculate the tip as : tip = 124.5 * 0.15 tip = 18.675 Credit: www.lawtantra.org
2nd Aug 2023, 6:09 AM
Novi
Novi - avatar
+ 2
It prints 50 as well , try removing that.
17th Feb 2021, 9:50 PM
Abhay
Abhay - avatar
+ 2
Truckin Dovahkiin what output does program expects?
17th Feb 2021, 10:04 PM
Abhay
Abhay - avatar
+ 1
O I wrote what you wrote nice thanks for help
17th Feb 2021, 10:18 PM
Truckin Dovahkiin
Truckin Dovahkiin - avatar
0
Tried it's still wrong says my input is 125 even though my input is 50
17th Feb 2021, 10:02 PM
Truckin Dovahkiin
Truckin Dovahkiin - avatar
0
It says input 125 my output 10.0 expected output 25.0
17th Feb 2021, 10:05 PM
Truckin Dovahkiin
Truckin Dovahkiin - avatar
0
Accidently figured out answer bill = int(input()) tip = (bill * 0.2) print(tip) I guess it didn't want anything input for bill and needed parentheses aroud bill * 0.2 The question at beginning said that the bill was 50 a tip at 20% so I thought I was solving the math problem and building the tip calculator but not solving the problem only building I feel dumb
17th Feb 2021, 10:15 PM
Truckin Dovahkiin
Truckin Dovahkiin - avatar
0
This took me a while but eventually I got there, here's my solution for this question. bill = int(input()) tip = (bill) * 20 / 100 print (tip)
21st Sep 2021, 3:49 PM
Darren Cassidy
0
I wrote my code like this and pass bill = int(input()) tip = .20 print(bill * tip) will this be good enough or will this be a problem later on?
21st Mar 2022, 10:55 PM
Ricardo Ramirez
0
Im stupid I was actually putting in a number so it kept solving one of the test and not the other🤦🏿‍♂️ I should've kept it blank
2nd Jun 2022, 7:20 PM
Sebastian Jn Baptiste
0
cash = int(bill) tip = (float(cash * (20/100))) print (tip)
28th Jan 2023, 12:37 AM
Jonathan Brown
Jonathan Brown - avatar
0
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double bill = sc.nextDouble(); //here is 15% of the bill double tip = bill*0.15; System.out.println(tip); } }
27th Mar 2024, 6:45 AM
W.D.V Gunarathna
W.D.V Gunarathna - avatar