[SOLVED] CPSC121-Lab3

20.99 $

Category:

Description

5/5 - (1 vote)

Create a program that:

  1. Prompt the user to choose between a rectangle and a triangle
  2. Prompt user for shape parameters
    1. Rectangle
      1. Ask user to choose between supplying a word or a width
      2. Ask user for height
    2. Triangle
      1. Ask user to choose between supplying a word or a width
      2. Ask whether the triangle points up or down
    3. Print the desired shape
      1. Ask the user whether they want to print to a file, “myshape.txt”, or to cout
        1. This can be accomplished using fewer lines of code by using the base ostream type as an argument, which ofstream and cout are both derived from. See here
      2. Ask the user if they would like to exit, or return to step 1

You must use at least two functions in this lab. How involved you get with them (including arguments, creating helper functions) is left up to you.

Points:

2 – Documentation, readability, format

2 – Proper program flow (conditionals, loops, etc)

1 – File output

  • – Functions
  • – Filename and Header2 – Output testing

Header

//<Your Name>

//CPSC 121 Lab 3

//<MM/DD/YY>

Filename

<Last Name><First Initial>lab3.cpp

For example, my assignment would be named MayElab3.cpp

//void DrawRectangle(int width, int height);

//DrawRectangle(5,3)

*****

*****

*****

//void DrawRectangle(string word, int height);

//DrawRectangle(“VOTE”, 3) shape.txt: VOTE

VOTE

VOTE

//void DrawTriangle(int size, bool pointingUp);

//DrawTriangle(4, true)

*

**

***

****

//void DrawTriangle(string word, bool pointingUp);

//DrawTriangle(“VOTE”, false)

VOTE

OTE

TE

E

//DrawTriangle(“VOTE”, true)

E

TE

OTE

VOTE