You are awarded from the SDSU Bookstore 1000 You can spend t
Solution
import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scan = new Scanner(System.in); //Input number of pencils,pens and notebooks
System.out.println(\"Enter the number of pencils,pens and notebooks\");
int n = scan.nextInt();
int m = scan.nextInt();
int k = scan.nextInt();
int count = 0;
//nested loops
for(int pencils = 0;pencils <=n;pencils++)
for(int pens =0; pens <=m;pens++)
for(int notebooks =0;notebooks <=k;notebooks++)
{
if((pencils*12 +pens*90 + notebooks*350 )<=1000) //total cost <=1000
count++;
}
System.out.println(\"The number of combinations : \"+count);
}
}
output:
Success time: 0.05 memory: 711680 signal:0
