Advertisement
Ang377ou

itemlist

Mar 23rd, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace activity5
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string[] items = {"FlatScreenMonitor", "Processor"," MotherBoard", "HD"," UPS"," Printer", "Scanner", "Memory", "Stand"," SystemCase"," WirelessRouter", "Headset"," Speaker", "Camera"," LANCard", "Mouse", "Chair", "Keyboard"};
  13. int[] Weight = {550, 200, 1000,750 ,1500 ,1000 , 1250,150,1000 ,10000 ,400 ,400 ,550 ,300 ,500 ,350,5000 ,400 };
  14. int[] Value = {15900,14250,12950,9450,5600,4700,4500,3800,2500,2400,1900,1300,1300,1050,980,750,500,250};
  15. string itemList = "";
  16. int totalweight = 0, totalvalue = 0,extra=0;
  17.  
  18. Console.Write("Max Weigth:");
  19. int weigth = int.Parse(Console.ReadLine());
  20.  
  21. for (int index = 0; index <= items.Length - 1; index++)
  22. {
  23. if (totalweight + Weight[index] <=weigth)
  24. {
  25. totalweight = totalweight + Weight[index];
  26. totalvalue = totalvalue + Value[index];
  27. itemList += items[index] + " = " + Weight[index].ToString() + "g--" + Value[index].ToString() + "\n";
  28. extra = totalweight - weigth;
  29. }
  30. }
  31. Console.WriteLine("\nITEMS:"+itemList+"\nTOTAL WEIGTH:"+totalweight+"\nTOTAL VALUE:"+totalvalue+"\nEXTRA MAX WEIGTH:"+extra);
  32. Console.ReadLine();
  33.  
  34.  
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement