Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. <script type="text/javascript">
  2. //Initialize variables
  3. let numberOfItems = 0;
  4. let itemIndex = 0;
  5. let itemNum = 0;
  6. let counter = 0;
  7. while(numberOfItems < 10) {
  8. numberOfItems = prompt("Enter the number of items in the auction (must be >= 10)")
  9. }
  10.  
  11. const itemCode = [];
  12. const itemDescription = [];
  13. const itemReservePrice =[];
  14. const itemHighestBid = [];
  15. const itemNumberOfBids = [];
  16. const itemSoldStatus = [];
  17. const itemBuyerCode = [];
  18. for(itemIndex = 1; itemIndex <= numberOfItems; itemIndex++) {
  19. counter = 1;
  20. if(itemIndex === 1) {
  21. itemNum = prompt("Enter the unique item number: ");
  22. }
  23. while(counter< itemIndex) {
  24. if(counter === 1) {
  25. itemNum = prompt("Enter the unique item number: ");
  26. }
  27. if(itemNum === itemCode[counter]) {
  28. alert(`The item number: ${itemNum} already exists!`);
  29. counter = 0;
  30. }
  31. counter++;
  32. }
  33. itemCode[itemIndex] = itemNum;
  34. itemDescription[itemIndex] = prompt("Enter the item description.");
  35. itemReservePrice[itemIndex] = prompt("Enter the item reserve price: ");
  36. itemHighestBid[itemIndex] = 0;
  37. itemNumberOfBids[itemIndex] = 0;
  38. itemSoldStatus[itemIndex] = false;
  39. itemBuyerCode[itemIndex]= 0;
  40. alert("Item code is: " + itemNum);
  41. alert("Item description");
  42. }
  43. alert(itemCode);
  44. </script>
  45. <!--
  46. DECLARE numberOf Items: INTEGER
  47. DECLARE itemIndex: INTEGER
  48. DECLARE itemNum: INTEGER
  49. DECLARE counter:INTEGER
  50. REPEAT
  51. OUTPUT “Enter the number of items in the auction (must be >= 10) “
  52. INPUT numberOfItems
  53. UNTIL numberOfItems >= 10
  54. DECLARE itemCode: ARRAY [1:numberOfItems] OF INTEGER
  55. DECLARE itemDescription: ARRAY [1: numberOfItems] OF STRING
  56. DECLARE itemReservePrice: ARRAY [1: numberOfItems] OF REAL
  57. DECLARE itemHighestBid: ARRAY [1: numberOfItems] OF REAL
  58. DECLARE itemNumberOfBids: ARRAY [1: numberOfItems] OF INTEGERL
  59. DECLARE itemSoldStatus: ARRAY [1: numberOfItems] OF BOOLEAN
  60. DECLARE itemBuyerCode: ARRAY [1: numberOfItems] OF INTEGER
  61. FOR itemIndex  1 TO numberOfItems
  62. counter  1
  63. IF itemIndex =1 THEN
  64. OUTPUT ("Enter the unique item number: ")
  65. INPUT itemNum
  66. ENDIF
  67. WHILE counter < itemIndex DO
  68. IF counter = 1 THEN
  69. OUTPUT ("Enter the unique item number: ")
  70. INPUT itemNum
  71. ENDIF
  72. IF itemNum = itemCode[counter] THEN
  73. OUTPUT ("The item number:already exists ")
  74. counter  0
  75. ENDIF
  76. counter  counter + 1
  77. ENDWHILE
  78. itemCode[itemIndex]  itemNum
  79. OUTPUT ("Enter the item description: ")
  80. INPUT itemDescription[itemIndex]
  81. OUTPUT ("Enter the item reserve price: ")
  82. INPUT itemReservePrice[itemIndex]
  83. itemHighestBid[itemIndex]  0
  84. itemNumberOfBids[itemIndex]  0
  85. itemSoldStauts[itemIndex]  false
  86. itemBuyerCode[itemIndex]  0
  87. NEXT itemIndex
  88. -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement