Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming problems in C++ (CodeBlocks) Thank you for your help Program 1 Write a code segment that adds up the positive integers, starting at 1,

Programming problems in C++ (CodeBlocks)

Thank you for your help

Program 1

Write a code segment that adds up the positive integers, starting at 1, until the sum equals or exceeds a value read from the keyboard, and then displays the last integer added to the sum use a do-while loop to do the summing.

Program 2

Write a do-while loop that prompts for and inputs a user's entry of "Y" or "N". If the user fails to enter a correct value, the loop outputs an error message and then repeats the request for the user to enter the value, again.

Program 3

7.3 You are working for a company that has traveling salespeople. The salespeople call in their sales to a fulfillment desk, where the sales are all entered into a file. Each sale is recorded as one line on the file sales.dat as a salesperson ID number, an item number, and a quantity, with all three items separated by blanks. There are 10 salespeople, with IDs of 1 through 10. The company sells eight different products, with IDs of 7 through 14 (some older products have been discontinued). The unit prices of the products are given here: Product Number 7 8 9 10 11 12 Unit Price 345.00 853.00 471.00 933.00 721.00 663.00 507.00 259.00 13 14 You have been asked to write a program that reads in the sales file and generates a separate file for each salesperson containing just that individual's sales. Each line from the sales file is copied to the appropriate salesperson file (salespers1.dat through salespers10. dat), with the salesperson ID omitted. The total for the sale (quantity times unit price) is appended to the record. At the end of processing, the total sales for each salesperson should be output with informative labels to cout. Use functional decomposition to design the program. Be sure that the program handles invalid ID numbers. If a salesperson ID is invalid, write an error message to cout. If a product number is invalid, write the error message to the salesperson's file and don't compute a total for that sale. There should be ample opportunity to use Switch statements and value-returning functions in this application.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions