Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace activity5
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] items = {"FlatScreenMonitor", "Processor"," MotherBoard", "HD"," UPS"," Printer", "Scanner", "Memory", "Stand"," SystemCase"," WirelessRouter", "Headset"," Speaker", "Camera"," LANCard", "Mouse", "Chair", "Keyboard"};
- int[] Weight = {550, 200, 1000,750 ,1500 ,1000 , 1250,150,1000 ,10000 ,400 ,400 ,550 ,300 ,500 ,350,5000 ,400 };
- int[] Value = {15900,14250,12950,9450,5600,4700,4500,3800,2500,2400,1900,1300,1300,1050,980,750,500,250};
- string itemList = "";
- int totalweight = 0, totalvalue = 0,extra=0;
- Console.Write("Max Weigth:");
- int weigth = int.Parse(Console.ReadLine());
- for (int index = 0; index <= items.Length - 1; index++)
- {
- if (totalweight + Weight[index] <=weigth)
- {
- totalweight = totalweight + Weight[index];
- totalvalue = totalvalue + Value[index];
- itemList += items[index] + " = " + Weight[index].ToString() + "g--" + Value[index].ToString() + "\n";
- extra = totalweight - weigth;
- }
- }
- Console.WriteLine("\nITEMS:"+itemList+"\nTOTAL WEIGTH:"+totalweight+"\nTOTAL VALUE:"+totalvalue+"\nEXTRA MAX WEIGTH:"+extra);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement