In: Computer Science
Problem1. James goes to restaurant for dinner. The items he orders are soup for $3.99, sandwich for $5.99 and a drink for $2.99, peach cobbler for $4.99. Calculate the subtotal, gratuity and total if the gratuity rate is 20%.
Problem2. Write a program which reads in an integer from the user and then prints out the last digit of the number that is 4 times the value which the user entered.
For example, if a user enters the number 52 , your program will compute the number 4*52=208 and print out the last digit which is 8.
Note: Use the modulo operator (%)
Problem3. Compute the volume of cylinder if the radius of the cylinder is 9 and length is 16. Assume the value of “pi” as 3.1415. Use the formula given below.
area = radius *radius*pi
volume = area *length
Answer 1:
subtotal=3.99+5.99+2.99+4.99
gratuity=subtotal*0.2
total=subtotal+gratuity
print("Sub total: ",subtotal)
print("Gratuity: ",gratuity)
print("Total: ",total)
Answer 2:
num=int(input("Enter number: "))
#adding 4 times
num=num*4
#printing last digit
print("Last digit: ",(num%10))
radius=9
length=16
pi=3.1415
#finding area
area = radius *radius*pi
#finding volume
volume = area *length
print("Area: ",area)
print("Volume: ",volume)
Note : If you like my answer please rate and help me it is very Imp for me