218k views
1 vote
Create a solution that accepts five integer inputs. Output the sum of the five inputs three times, converting the inputs to the requested data type prior to finding the sum.

User Kinghomer
by
8.1k points

1 Answer

3 votes

Final answer:

To solve this problem, we need to write a solution that accepts five integers as inputs. We can do this by using a loop to prompt the user for input five times. Next, we need to convert the inputs to integers using the parseInt() function.

Step-by-step explanation:

To solve this problem, we need to write a solution that accepts five integers as inputs. We can do this by using a loop to prompt the user for input five times. Next, we need to convert the inputs to integers using the parseInt() function.

Once we have the five integers, we can find their sum by adding them together. We can store the sum in a variable and then output it three times using a loop.

Here is an example solution in JavaScript:

let sum = 0;

for (let i = 0; i < 5; i++) {
let input = parseInt(prompt('Enter an integer: '));
sum += input;
}

for (let i = 0; i < 3; i++) {
console.log('Sum:', sum);
}

User Fahad Abid
by
9.2k points