Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- //Initialize variables
- let numberOfItems = 0;
- let itemIndex = 0;
- let itemNum = 0;
- let counter = 0;
- while(numberOfItems < 10) {
- numberOfItems = prompt("Enter the number of items in the auction (must be >= 10)")
- }
- const itemCode = [];
- const itemDescription = [];
- const itemReservePrice =[];
- const itemHighestBid = [];
- const itemNumberOfBids = [];
- const itemSoldStatus = [];
- const itemBuyerCode = [];
- for(itemIndex = 1; itemIndex <= numberOfItems; itemIndex++) {
- counter = 1;
- if(itemIndex === 1) {
- itemNum = prompt("Enter the unique item number: ");
- }
- while(counter< itemIndex) {
- if(counter === 1) {
- itemNum = prompt("Enter the unique item number: ");
- }
- if(itemNum === itemCode[counter]) {
- alert(`The item number: ${itemNum} already exists!`);
- counter = 0;
- }
- counter++;
- }
- itemCode[itemIndex] = itemNum;
- itemDescription[itemIndex] = prompt("Enter the item description.");
- itemReservePrice[itemIndex] = prompt("Enter the item reserve price: ");
- itemHighestBid[itemIndex] = 0;
- itemNumberOfBids[itemIndex] = 0;
- itemSoldStatus[itemIndex] = false;
- itemBuyerCode[itemIndex]= 0;
- alert("Item code is: " + itemNum);
- alert("Item description");
- }
- alert(itemCode);
- </script>
- <!--
- DECLARE numberOf Items: INTEGER
- DECLARE itemIndex: INTEGER
- DECLARE itemNum: INTEGER
- DECLARE counter:INTEGER
- REPEAT
- OUTPUT “Enter the number of items in the auction (must be >= 10) “
- INPUT numberOfItems
- UNTIL numberOfItems >= 10
- DECLARE itemCode: ARRAY [1:numberOfItems] OF INTEGER
- DECLARE itemDescription: ARRAY [1: numberOfItems] OF STRING
- DECLARE itemReservePrice: ARRAY [1: numberOfItems] OF REAL
- DECLARE itemHighestBid: ARRAY [1: numberOfItems] OF REAL
- DECLARE itemNumberOfBids: ARRAY [1: numberOfItems] OF INTEGERL
- DECLARE itemSoldStatus: ARRAY [1: numberOfItems] OF BOOLEAN
- DECLARE itemBuyerCode: ARRAY [1: numberOfItems] OF INTEGER
- FOR itemIndex 1 TO numberOfItems
- counter 1
- IF itemIndex =1 THEN
- OUTPUT ("Enter the unique item number: ")
- INPUT itemNum
- ENDIF
- WHILE counter < itemIndex DO
- IF counter = 1 THEN
- OUTPUT ("Enter the unique item number: ")
- INPUT itemNum
- ENDIF
- IF itemNum = itemCode[counter] THEN
- OUTPUT ("The item number:already exists ")
- counter 0
- ENDIF
- counter counter + 1
- ENDWHILE
- itemCode[itemIndex] itemNum
- OUTPUT ("Enter the item description: ")
- INPUT itemDescription[itemIndex]
- OUTPUT ("Enter the item reserve price: ")
- INPUT itemReservePrice[itemIndex]
- itemHighestBid[itemIndex] 0
- itemNumberOfBids[itemIndex] 0
- itemSoldStauts[itemIndex] false
- itemBuyerCode[itemIndex] 0
- NEXT itemIndex
- -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement