Write a program using variables to find the cost
of 17 pencils if the cost of one pencil= `2.50.
Output should be: Cost of 1 pencil=`2.5
Cost of 17 pencils=`42.5
Class 9 - Computer Applications - Ch 3
Answers
Answered by
26
Hey there!
Answer:
public class Question
{ static void main()
{ float rate=2.50f, cost;
int pencils=17;
cost=pencils*rate;
System.out.println("Cost of 1 pencil= Rs "+rate);
System.out.println("Cost of 17 pencils= Rs "+cost);
} }
Hope It helps You!
Similar questions