Forum Moderators: open
/* Program to enter the five whole numbers which are the total numbers of library books borrowed and store them in an array */
var bookArray = new Array (5);
var weekdayArray = ['Monday','Tuesday','Wednesday','Thursday','Friday']
document.write('Program that displays five whole numbers which are the total number of library books borrowed by a group of students on five successive days.');
for (var day = 0; day < bookArray.length; day = day + 1)
{
bookArray[day] = window.prompt('Enter a whole number for a day ' + (day + 1),'')
};
document.write('<BR>' + '<BR>');
document.write('Confirmation of five whole numbers input' + '<BR>' + '<BR>');
for (var day = 0; day < bookArray.length; day = day + 1)
{
document.write(bookArray[day] + '<BR>')
}
</SCRIPT>
The above program prompt students to input the number of books they borrowed from a public library. How do I notify the students what days of the week they are entering value for?
<SCRIPT >
/* Program to read in a known number of data items and store them in an array */
var booksArray = new Array (5);
var dayNamesArray = ['Monday','Tuesday','Wednesday','Thursday','Friday'];
document.write('Program that list total number of books borrowed from a library');
for (var day = 0; day < booksArray.length; day = day + 1)
{
booksArray[day] = window.prompt('Enter number of books borrowed on ' + (dayNamesArray + 1),'')
};
document.write('<BR>' + '<BR>');
document.write('Confirmation of number of books borrowed on weekdays' + '<BR>' + '<BR>');
for (var day = 0; day < booksArray.length; day = day + 1)
{
document.write(dayNamesArray[day] + ' : ' + booksArray[day] + '<BR>')
}
</SCRIPT>