Computer Applications
A store has purchased some cola cans of various brands. It purchased 50 cans @ ₹15 per can, 30 cans @ ₹20 per can and 40 cans @ ₹21 per can. Write a Java program to compute how much amount did the store pay.
Java
Java Operators
15 Likes
Answer
public class KboatColaCans
{
public static void main(String args[]) {
int can1 = 50;
int can2 = 30;
int can3 = 40;
int p1 = 15;
int p2 = 20;
int p3 = 21;
int amt = can1 * p1 + can2 * p3 + can3 * p3;
System.out.println("Amount to be paid = " + amt);
}
}
Output

Answered By
8 Likes
Related Questions
if (a>b&&b>c) then largest number is:
- b
- c
- a
- wrong expression
If the value of basic=1500, what will be the value of tax after the following statement is executed?
tax = basic > 1200 ? 200 :100;
A student executes the following code to increase the value of a variable ‘x’ by 2.
He has written the following statement, which is incorrect.
x = +2;
What will be the correct statement?
A. x +=2;
B. x =2;
C. x = x +2;- Only A
- Only C
- All the three
- Both A and C
If
x = 5
andy = 4
, what will be the output of the following code?x += ++y - x-- + y++; System.out.println("x = " + x); System.out.println("y = " + y);