STUDYSHIELDS ASSIGNMENT HELP

  • Home
  • Blog
  • Courses
    • Child Category 1
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Services
  • Country
    • Childcare
    • Doctors
  • Home
  • Blog
  • Sample Works
  • Order Now

Thursday, February 18, 2016

To use functions with parameters and a menu, introducing the technique of stepwise refinement

 February 18, 2016     No comments   

Objective:
To use functions with parameters and a menu, introducing the technique of stepwise refinement.
c   [the already written in Lab 10] greatest-common-factor code is made into a function for use in reducing fractions and finding the common denominator to add/subtract fractions.
c   there should be a separate function for each operation
c   there should be a function for outputting the problem/solution/reduced fraction
c   error checking (Hint: think about where all the errors could come from)
Assignment:
Write a menu-driven program that manipulates fractions.  Using the idea of stepwise refinement, you should write a function for each arithmetic operation.  This is “stepwise” because we are breaking the problem into more manageable pieces and dealing with each in turn.  Additionally, you should have a function that will get a fraction and check its validity (i.e., denominator not equal to zero).
Your program should ask the user to input two fractions and to select an operation (+, -, *, /).  Then, it should display the problem along with the solution.  The program should recognize division by zero and print an appropriate error message.  It should loop around until the user chooses to quit.
Test your program with positive and negative fractions and with zeroes.
Reduce all answers.  Displaying the reduced fraction only if different from the original.  Do not leave a fraction with denominator of 1.
Sample Run:

Enter the numerator and denominator of the first fraction:  5 6
Enter the numerator and denominator of the second fraction: 1 3

Menu of Operations
Add...................1
Subtract..............2
Multiply..............3
Divide................4

Which operation? 2

5    1    3    1
---  -  ---  =  ---  =  ---
6    3    6    2

Another problem (y for yes, n for no)? n



Lab 13
Stars
Objective
To explore nested for loops and the use of the index variable.
Assignment
Read the following code carefully.  In the box, write out what you predict the output will be.
#include <iostream>
using namespace std;
     



int main()
{
 int row, col;
 cout << endl;
 for(row = 0; row < 5; row++)
 {
   for(col = row; col >= 0; col --)
  cout << "*";
   cout << endl;
 }
 return 0;
}

Type in and run the code to see if you were right.
Now, write a C++ program that will generate the following patterns.  Note that you must use for loops and may not use any if statements! Each of the designs should be implemented in a separate function or functions.  This needs to work for any size grid and each generated pattern should have the same number of rows.
*******
******
*****
****
***
**
*

  *
**
***
  ****
 *****
******
*******

  *
***
*****
  *******
 *********
***********
*************
For the final pattern, you may use if statements, but you may not simply output the text of the pattern using cout.  This pattern should be generated by a function and have the same number of rows as the previous patterns.
*******
**   **  (Note: This pattern is
* * * *   a square.)
*  *  *
* * * *
**   **
*******
Make sure each function accepts a single integer parameter N and draw your patterns to a height of N rows.
Lab 14
Miniature Golf
Objective:
To gain more experience with one-dimensional arrays of fixed length.
Assignment:
Write a program, containing 3 functions, that asks the user for the number of strokes taken on each hole of an 18-hole miniature golf course, calculates the final score, and prints out a scorecard.  Also state how many holes-in-one the player had.

Remember when you pass your array it is a reference parameter, even if you are not changing its contents.  Just be careful that you are not accidentally making any modifications.

Output for scorecard should look just like what you see below, with proper spacing and alignment.

Sample Run:

Enter name of player: Dylan
Enter the number of strokes for each hole.
 hole[1]: 3
 hole[2]: 1
:
 hole[18]: 5

Dylan, here is your scorecard:
Hole :  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18
------------------------------------------------------------
Score:  3  1  6  4  2  3  3  1  2  4  5  3  2  2  2  3  4  5

Your total is 55.
You scored 2 holes-in-one.

Hint:
The field width manipulator setw (found in the header file iomanip) will right-justify the number that follows in a field 3 characters wide.

  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Click Here to Place order

Popular Posts

  • A “criminal minds” Aileen Wournos individual will be your “patient”
     A “criminal minds” Aileen Wournos individual will be your “patient”  A brief history of the patient including diagnoses (documented or your...
  • CEO Jane Lionel has some hard decisions to make with regard to some of the company’
     CEO Jane Lionel has some hard decisions to make with regard to some of the company’solder hands, and even on the eve of that decision, I be...
  • Problem in Supply Chain
    Problem in Supply Chain Problem 2. (Chapter 11: The Storage and Handling System) Compare the constrast private ownership of storage space to...

Recent Posts

Unordered List

Pages

  • Home

Text Widget

Blog Archive

  • November 2022 (20)
  • October 2022 (50)
  • September 2022 (119)
  • August 2022 (107)
  • February 2022 (501)
  • January 2022 (443)
  • December 2021 (488)
  • November 2021 (1574)
  • October 2021 (28)
  • September 2021 (11)
  • July 2021 (8)
  • June 2021 (15)
  • May 2021 (39)
  • April 2021 (15)
  • March 2021 (303)
  • February 2021 (712)
  • January 2021 (903)
  • December 2020 (2)
  • September 2020 (33)
  • April 2016 (5183)
  • March 2016 (3763)
  • February 2016 (4356)
  • January 2016 (1749)
  • December 2015 (22)
  • November 2015 (147)
  • October 2015 (23)

Sample Text

Copyright © STUDYSHIELDS ASSIGNMENT HELP | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates