Program Specifications • Carefully read the entire Program Specification before beginning. • FOLLOW THE SPECIFICATIONS B

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Program Specifications • Carefully read the entire Program Specification before beginning. • FOLLOW THE SPECIFICATIONS B

Post by answerhappygod »

Program Specifications Carefully Read The Entire Program Specification Before Beginning Follow The Specifications B 1
Program Specifications Carefully Read The Entire Program Specification Before Beginning Follow The Specifications B 1 (117.44 KiB) Viewed 31 times
Program Specifications • Carefully read the entire Program Specification before beginning. • FOLLOW THE SPECIFICATIONS BELOW TO create the following functions to calculate and display the sum or product of the integers from 1 to the number input. • getNum • Receives no input. Prompts the user to enter an integer. Uses a loop to validate. Insures that no number, entered, is negative or zero. Returns the result. • calcSum Receives an integer as input. USE AN ACCUMULATOR to calculate the sum of the integers from 1 to this number. Returns the result. • calcProd · Receives an integer as input. USE AN ACCUMULATOR to calculate the product of the integers from 1 to this number. Returns the result.
Program Specifications • Main should: • Prompt for a character that determines if you want to calculate the sum ('S' or 's') or product ('P' or 'p'). If a valid option is entered, use getNum to prompt for the number • Note that calcSum and calcProduct RETURN the result to main, and the output is printed in main. • For example, if you input 5 as the number, and 'S', the program should calculate 1+ 2+ 3+ 4+ 5 and display the sum as 15. If you input 5 and 'P' the program should calculate 1 x 2 x 3 x 4 x 5 and display the product as 120. • The process should repeat as long as the user wants to continue. This loop should be in main.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply