Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- string[] i = { "flatscreen monitor", "processor", "motherboard", "HD", "UPS", "printer", "scanner", "memory", "stand", "system case", "wireless router", "headset", "speaker", "camera", "LAN Card", "Mouse", "Chair", "Keyboard" };
- int[] v = { 15900, 14250, 12950, 9450, 5600, 4700, 4500, 3800, 2500, 2400, 1900, 1300, 1300, 1050, 980, 750, 500, 250 };
- int[] w = { 550, 200, 1000, 750, 1500, 1000, 1250, 150, 10000, 1000, 400, 400, 550, 300, 500, 350, 5000, 400 };
- int[] I = {2,3,5,4,5,1,3,2,2,1,1,3,5,5,5,1,3,1 };
- int weight, sum = 0;
- string Items = "";
- int index = 0, totalweight = 0, totalvalue = 0;
- Console.Write("Input Weight: ");
- weight = int.Parse(Console.ReadLine());
- while (sum <= weight && index < w.Length)
- {
- if (sum + w[index] <= weight)
- {
- totalweight = totalweight + w[index];
- totalvalue = totalvalue + v[index];
- sum = sum + w[index];
- Items = Items + i[index] + " sucks in the bag with " + w[index] + " grams " + " and " + v[index] + " Pesos \n";
- I[index] = I[index] - 1;
- }
- if (I[index] == 0 || w[index] > (weight - sum))
- {
- index++;
- }
- }
- Console.WriteLine( Items + "\ntotal weight :"+totalweight.ToString()+"\ntotal value :" +totalvalue.ToString());
- Console.ReadKey();
- }
- //CODED BY JGT @ ASIAN COLLEGE OF TECHNOLOGY
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement