Answer:
The code will produce:-
2.4
Explanation:
In this code the result of the arithmetic operation is stored in the variable c.On evaluating the expression it divides 12.0 by 5 which results in 2.4 and it is stored in float variable c.Then it is printed on the screen using print statement.Since the c is double variable so the result will be a decimal number.
Hence the answer is 4.
Answer:
import java.io.*;
import java.util.Scanner;
class divide {
public static void main (String[] args) {
Scanner num=new Scanner(System.in);//scanner object.
int userNum=num.nextInt();
while(userNum>1)//while loop.
{
userNum/=2;//dividing the userNum.
System.out.print(userNum+" ");//printing the userNum.
}
}
}
Input:-
40
Output:-
20 10 5 2 1
Input:-
2
Output:-
1
Input:-
0
Output:-
No Output
Input:-
-1
Output:-
No Output.
Explanation:
In the program While loop is used.In the while loop it divides the userNum by 2 in each iteration and prints the value of userNum.The inputs and corresponding outputs are written in the answer.
Explanation:
It's placed near the door. When a visitor presses the button, the bell rings inside alerting you that someone is at the door.
The presentation theme determines the formatting characteristics of fonts and colors.
Answer:
#here is code in python.
# read the food bill
tot_bill=float(input("Please enter the food bill:"))
# tax on food
tax=0.06
#choice for tip by user
choice=int(input("enter your choice for tip:(1 for 15%, 2 for 18% and 3 for 20% :)"))
// calculate the total food bill
if choice==1:
tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.15)
elif choice==2:
tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.18)
elif choice==3:
tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.2)
else:
print("invalid choice:")
#print the total food bill
print("total food bill is ",tot_food_bill)
Explanation:
Read the food bill from user and assign it to variable "tot_bill".Initialize the tax=0.06 (i.e. 6%) on the bill.Then ask user to give his choice for tip. if the choice is 1 then tip will be 15%, if 2 then 18% and if choice is 3 Then tip will be 20% of the bill.Calculate the total food bill and assign it to variable "tot_food_bill".
Output:
Please enter the food bill:100
enter your choice for tip:(1 for 15%, 2 for 18% and 3 for 20% :)2
total food bill is 124.0