+ 2
Please,help me to write a program to prompt the user for Hours and Rate Per Hour to compute Gross Pay
Assignment
10 odpowiedzi
+ 5
Please show us your attempt and link your code here.
+ 2
Ok,l will get back.
Thanks 👍
+ 2
If you're looking to have the output more visually appealing, do this instead to get your desired effect.
x = float(input("Enter your hours: "))
print(str(x))
y = float(input('Enter your hourly rate: '))
print(str(y))
pay = str(x*y)
print('Pay: ' + pay)
https://code.sololearn.com/cA182a24A19A
::INPUT::
35
2.75
::OUTPUT::
Enter your hours: 35.0
Enter your hourly rate: 2.75
Pay: 96.25
+ 1
print('Enter your hours:')
x = float(input())
print('Enter your hourly rate:')
y = float(input())
pay = str(x*y)
print('Pay: ' + pay)
INPUT:
40
10
OUTPUT:
400.0
Code Playground: https://code.sololearn.com/cA182a24A19A
input() is how you get the prompt, and you assign it to a variable to store the value that's inputted. You wrap it in float() to ensure the value is stored as an int that we can use to do calculations, and then I used str() to ensure it's a text string that we can easily print out to display the result.
Hope that helps. Good luck in your learning.
+ 1
In the CodePlayground, you have to input all inputs into the same box when you run it. So for example you would put:
35
2.75
^Put that into the input box on separate lines as above.
Then when it finishes execution it'll output 96.25 as you expect. This is a security feature since you're executing code through the servers instead of locally.
0
Ok,l will get back.
Thanks 👍
0
Lisa
0
Lisa, thanks 👍 very much may God bless you.
0
Jako jak,the code only give me output like this: "Enter hours :35"
But, this is how my question should be Outputted;
Enter Hours: 35
Enter Rate: 2.75
Pay: 96.25
0
Thank you for the tuition,I will try it and then get back to you.