+ 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
15 Respostas
+ 14
Then just do,
bill=int(input())
tip=bill*0.2
print(tip)
And it should work fine.
+ 7
Abhay thanks buddy it works well ☺️
+ 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
+ 2
It prints 50 as well , try removing that.
+ 2
Truckin Dovahkiin what output does program expects?
+ 1
O I wrote what you wrote nice thanks for help
0
Tried it's still wrong says my input is 125 even though my input is 50
0
It says input 125 my output 10.0 expected output 25.0
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
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)
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?
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
0
cash = int(bill)
tip = (float(cash * (20/100)))
print (tip)
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);
}
}
0
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);
}
}