Series of arithmetic problems

Assignment Help C/C++ Programming
Reference no: EM13808353

Assignment

This program will ask the user to answer a series of arithmetic problems and report on how the user performs. You will write this program in phases as specified below. Make sure that each phase works correctly and uses good style before progressing to the following phase.

Note that the purpose of this assignment is to give you lots of practice with parameter passing without making you write a huge program. For this reason I have provided a structure diagram at the end of this document. Make sure that you adhere to the structure diagram carefully.

Turn in only your final product.

Phase 1: Your main function for phase I must look exactly like this:

    int main()

    {

        srand(time(0));   

        doOneSet();

    }

You must write the function doOneSet which will, for now, write out 5 addition problems. All of the numbers printed should be between 0 and 100, inclusive. Here is a sample output for this phase:

    45 + 21 =

    0 + 100 =   

    54 + 23 =   

    4 + 19 =

    18 + 92 =

The numbers that are produced for these problems must be generated randomly by the computer. The numbers in the sample output are given only as an example.

Phase 2: Change your doOneSet function so that instead of just writing out the problems it also allows the user to enter an answer, and then tells the user whether the answer was correct or not. Do not change your main function. Here is the sample output for this phase (user input is indicated here by using bold font. It won't be bold in your own output):

    45 + 21 = 66

    correct

    0 + 100 = 100   

    correct  

    54 + 23 = 67

    incorrect

    4 + 19 = 13

    incorrect

    18 + 92 = 110

    correct

Before you move on to phase 3, refer to the structure diagram at the end of this document and make sure that you have adhered to it for all of the functions indicated there for phase 2. This will probably mean dividing your doOneSet function up into functions, if you haven't done it already.

Phase 3: Now you will change your doOneSet function so that it will work for either addition, subtraction, or multiplication. For the purposes of this assignment, a set of problems is defined to be a group of problems that are all of the same type (all addition, all subtraction, or all multiplication). After completing this phase your program will give 5 addition problems, 5 subtraction problems, and 5 multiplication problems, for a total of 15 problems. Your main function must look exactly like this:

    int main()

    {

        srand(time(0));   

        doOneSet('+');

        doOneSet('-');

        doOneSet('*');

    }

The parameter tells doOneSet whether to do addition, subtraction, or multiplication. Notice that there is exactly one doOneSet function definition, not three! Here is the sample output for this phase:

    45 + 21 = 66

    correct

    0 + 100 = 100   

    correct

    54 + 23 = 67

    incorrect

    4 + 19 = 13

    incorrect

    18 + 92 = 100   

    correct

    59 - 19 = 40

    correct

    19 - 84 = -29   

    incorrect

    0 - 65 = -65

    correct

    96 - 1 = 95

    correct

    94 - 14 = 80

    correct

    0 * 87 = 0

    correct

    45 * 84 = 398

    incorrect

    8 * 37 = 873

    incorrect

    34 * 83 = 831

    incorrect

    38 * 3 = 238

    incorrect

Phase 4: Now you are ready to let the user specify how many problems per set. (Recall that a set is a group of problems all of the same type. In this program we are doing three sets: one set of addition, one set of subtraction, and one set of multiplication. This means that, for example, if the problems per set is 7, there will be a total of 21 problems given.) Ask the user to enter the number of problems per set at the very beginning of the program, so that all three sets have the same number of problems per set. Now your main function will look exactly like this except that you may add variable declarations in the indicated location:

    int main()

    {

        <you may add variable declarations here>

        srand(time(0));

        getProbsPerSet(probsPerSet);  

        doOneSet('+', probsPerSet);   

        doOneSet('-', probsPerSet);

        doOneSet('*', probsPerSet);

    }

For this phase you should also add a header at the beginning of each set, as illustrated in the following sample output for this phase. For purposes of the header, you should assume that the addition problems will always be set #1, the subtraction problems set #2, and the multiplication problems set #3.

    Enter problems per set: 3   

    Set #1

    ----------

    45 + 21 = 66

    correct

    0 + 100 = 100   

    correct

    54 + 23 = 67

    incorrect

    Set #2

    ----------

    59 - 19 = 40

    correct

    19 - 84 = -29   

    incorrect

    0 - 65 = -65

    correct

    Set #3

    ----------

    0 * 87 = 0

    correct

    45 * 84 = 398

    incorrect

    8 * 37 = 873

    incorrect

Phase 5: Now let the user specify maxNum, the maximum number to be used for each set. This means that instead of choosing numbers between 0 and 100 (inclusive) for each problem, the computer will be choosing numbers between 0 and maxNum (inclusive). You must allow the user to enter a different maximum number for each set. This won't change the main function, since you need to ask it again before each set. It will be done near the beginning of your doOneSet function. Here's the sample screen output:

    Enter problems per set: 3   

    Set #1

    ----------

    What is the maximum number for this set? 100   

    45 + 21 = 66

    correct

    0 + 100 = 100   

    correct

    54 + 23 = 67

    incorrect

    Set #2

    ----------

    What is the maximum number for this set? 90

    59 - 19 = 40

    correct

    19 - 84 = -29   

    incorrect

    0 - 65 = -65

    correct

    Set #3

    ----------

    What is the maximum number for this set? 20

    0 * 18 = 0

    correct

    15 * 4 = 398

    incorrect

    8 * 17 = 873

    incorrect

Phase 6: Now you need to keep track of how the user is doing. after the user has attempted all of the problems, your program should write a report that says how many the user got right on each set out of how many and for what percent. The percent must be rounded to the nearest integer, as illustrated in the sample output. The report must also indicate the overall figures. Here's a sample screen output:

    Enter problems per set: 3   

    Set #1

    ----------

    What is the maximum number for this set? 100   

    45 + 21 = 66

    correct

    0 + 100 = 100   

    correct

    54 + 23 = 67

    incorrect

    Set #2

    ----------

    What is the maximum number for this set? 90

    59 - 19 = 40

    correct

    19 - 84 = -29   

    incorrect

    0 - 65 = -65

    correct

    Set #3

    ----------

    What is the maximum number for this set? 20

    0 * 18 = 0

    correct

    15 * 4 = 398

    incorrect

    8 * 17 = 873

    incorrect

    Set#1:  You got 2 correct out of 3 for 67%

    Set#2:  You got 2 correct out of 3 for 67%

    Set#3:  You got 1 correct out of 3 for 33%

    Overall you got 5 correct out of 9 for 56%

Your main function for phase 6 must look like this, except that you may add variable declarations and arguments in the indicated locations:

    int main()

    {

        <variable declarations>

        srand(time(0)); 

        getProbsPerSet(<arguments>); 

        doOneSet(<no-more-than-3-arguments>);   

        doOneSet(<no-more-than-3-arguments>);

        doOneSet(<no-more-than-3-arguments>);

        printReport(<arguments>);

    }

Notice that you may send no more than 3 arguments to doOneSet. Hint: Although main will need three separate variables to keep track of the number of problems answered correctly in each set, your doOneSet function will have only one parameter that keeps track of the nmber of problems answered correctly in the current set. It will be up to main to get that information into the correct variable.

The following structure diagram includes every function that you will have in your program. You should have no more and no fewer, and you should use the names that have been indicated here. Please also read the notes below the structure diagram very carefully.

Reference no: EM13808353

Questions Cloud

Debt and common stock : A firm has determined its optimal structure which is composed of the following sources and target market value proportions. Debt: The firm can sell a 15-year, $1,000 par value, 8 percent bond for $1,050. A flotation cost of 2 percent of the face valu..
Dynamic behavior of the working pointers : Dynamic behavior of the working pointers the four LinkedList Methods: Append(), Display(), Insert(), and Delete() in the Chapter 17 LinkedList Template (LinkedList.h) Version 2
Explain how the federal government promotes business : Explain how the federal government promotes business, labor, and agriculture in the United States. Also, describe how the federal government uses its monetary policy as an economic management tool.
Normal distribution and standard deviation of the population : What percentage of the time does a lathe produce more than 27 components per hour?
Series of arithmetic problems : This program will ask the user to answer a series of arithmetic problems and report on how the user performs. You will write this program in phases as specified below. Make sure that each phase works correctly and uses good style before progressin..
Measurement strategies : Measurement Strategies
Does warranty accrual decision create any ethical dilemma : Does the warranty accrual decision create any ethical dilemma for Bly - Since warranty expenses vary, what percent do you think Bly should choose for the current year? Justify your response.
What is your initial level of education in nursing : Normal 0 false false false EN-US X-NONE X-NONE What is your initial level o..
Find confidence interval for the population mean annual numb : 1) Twenty-eight small communities in Connecticut (population near 10,000 each) gave an average of x = 138.5 reported cases of larceny per year. Assume that σ is known to be 42.7 cases per year. (a) Find a 90% confidence interval for the population me..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Compute the power loss in a transmission line

Write a program to compute the power loss in a transmission line with a resistance of 0.05 ohms/mile. Compute the power loss if 500 kw of power is transmitted from a power generating station to cities at distances of 20, 30, 40, 50,....., 100 mile..

  Write a program that prompts for and gets a student name

Write a program that gets 10 numbers and stores then in an array. Then sort (low to high) the number using a function.

  Lab9 c lab 9 c i request this twice but no answer on this

lab 9 c ltbrgti request this twice but no answer on this please could you check this for

  Program that generates 50,000 random integers

Program that generates 50,000 random integers from 1 to 6 (inclusive). Count the number of times that each number occurs and output the totals

  Write the output of the program

Design a C++ program that will interactively prompt for and read the name of the input file interactively prompt for and read the name of a file to write the output of the program to write the following to the specified output file your name, sect..

  Computer program the requirements are attached please see

the requirements are attached. please see them. the program should be done in c or c. also i need read me file to tell

  Write and test c program which outputs waveform

Write and test a C program which outputs waveform which switches from 10.0 kHz with a 50% duty cycle to 25.0 kHz with a 5% duty cycle every 5 seconds.

  Write a program to check whether a number is even or odd

Write a C++ program to check whether a number entered by user is even or odd.

  Write a program that grades the written portion

The local driver's license office has asked you to write a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions.

  Design for storing the maze layout

Design and implement a C++ program for maze layout

  Write a program that displays the cubes of the numbers

Write a program that displays the cubes of the numbers from 1 to 10. Recall that the cubes of a number is just the number multiplied by itself and then by itself again.

  Write a program that uses a string array to store a list

The program should allow the user via a menu to add an item to the list, clear the list, and display the list. You may assume that the list will never need to contain more than 10 items.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd