Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ programming Lab 6 Work You always create a separate C++ file for each program you write in the lab. 1. Write a C++ program

C++ programming

image text in transcribed
Lab 6 Work You always create a separate C++ file for each program you write in the lab. 1. Write a C++ program that does the following: Create a C++ file with the name problem1.cpp. Calculates and prints how much a person earns over a period of time if his/her salary is one penny the first day, two pennies the second day, and continues to double each day. How many days will it take for the person's daily salary to exceed $10,000? Print a table showing the day number and the salary per day in dollars. Use a tab to separate the two columns. You type \\t for a tab character inside a string. The sample run below shows just the first nine days, but your program prints all days until the salary exceeds $10,000. Sample run of the program: Day Salary: 0.01 0.02 0.04 0.08 0.16 0.32 0.64 1.28 2.56 oR mean O XN B W~ 2. Write a C++ program that does the following: a. Create a C++ file with the name problem2.cpp. b. Prompt the user for a positive integer, validating the input until the user enters a positive integer. c. Print the positive integer in binary backwards as follows: 'While the number is greater than zero, print the number % 2, followed by replacing the number by number /2, Sample run of the program: Enter a positive integer: 2 Invalid input! Try again: 20 Your number in binary in reverse orderis: 00 10 1 3. Write a C++ program that does the following: a. Create a C++ file with the name problem3.cpp. b. Prompt the user for a positive integer, validating the input until the user enters a positive integer. c. Print all the factors of the positive integer. d. Number x is a factor of number y, when the remainder of y divided by x is 0. Sample run of the program: Enter a positive integer: 71 Invalid input! Try again: 42 The factors of 42 are: 12367 1421 42 4. Write a C++ program that does the following: a. Create a C++ file with the name problem4.cpp. b. Prompt the user to enter the price of his/her items. c. The user can enter as many items as he/she wants until the user enters the integer 0. d. Print out the total of his/her checkout. e. Ifthe sum is greater than $100, print out That's expensive! Sample run of the program: Enter the price of an item (enter 0 to stop): 27 Enter the price of an item (enter 0 to stop): 80 Enter the price of an item (enter 0 to stop): 0 Your checkout total is $107. That's expensive! 5. Write a C++ program that does the following: a. Create a C++ file with the name problem5.cpp. b. Prompt the user for a positive integer, validating the input until the user enters a positive integer. c. Use a while loop to compute the sum of all odd digits of the number. Sample run of the program: Enter a positive integer: 237 Invalid input! Try again: 237 The sum of the odd digits in the number is 10. Lab Work Submission: You can continue to work on this lab after our lab class, on your own, at home. Submit your lab work via Blackboard on or before: Sunday, March 10, 2024. This is the only accepted submission method! Once you submit your assignment you will not be able to resubmit it! Make absolutely sure the C++ files you want to submit are the C++ files you want graded. You will not be able to submit your lab work under any circumstances once Lab 6 Work disappears at 12:00 a.m. on Monday, March 11, 2024. There will be NO exceptions to these rules! To submit your lab work, upload the 5 C++ files you did for this lab (with .cpp extension) to the Lab 6 Work assignment in the Lab Work tab in the course's presence in Blackboard. e Then, make sure you click the Submit button to submit your lab work. The lab work is worth a total of 8 points based only on grading one of the problems (a randomly chosen one). Grading steps for the chosen problem are as follows: 1. If your program does NOT compile successfully, then the grade for the lab is zero. 2. Ifyour program produces runtime errors or does NOT produce the expected output, then the grade for the lab is zero. 3. Ifthe program compiles, runs, and produces the expected output, then the grade is computed as follows: a. 7 points the program compiles, runs, and produces the expected output b. 1 point - proper indentation and formatting of the code

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions