Problem: Suppose you are at a supermarket and purchased some product, WAP to add the price of all the products. You are having only 5000, so, you need to stay in your budget.
Solution:
import java.util.*;
class Calc
{
public static void main(String args[])
{
int sum=0,num;
Scanner scan = new Scanner(System.in);
System.out.println("Start adding the number: ");
for(;;)
{
num = scan.nextInt();
sum=sum+num;
System.out.println(sum);
}
}
}
0 comments:
Post a Comment