![]() |
|
#11
|
|||
|
|||
Re: Two or more data types in declaration errorQuote:
Here are the requirements: Write a program to prompt the user for a shape code. Read the shape code from the keyboard. Based on the shape code entered, prompt for the measurement(s) needed to calculate the area for that shape. Read the measurement(s) from the keyboard. Calculate the area of the shape. Print the area on the monitor. Allow the user to continue entering shape codes and values until he/she indicates no more processing is required. When the user does not want to continue, print a closing message. Print an overview of the program's purpose. This should be in terms a user would understand. Make sure this is printed only once per program execution. Place this code in a function and call this function from main. Write at least three other functions which are called from main. Examples of possible functions: get user input, calculate area for a shape, print output. Make at least one function receive an argument or arguments and at least one function return a return value other than 0 or void using the return statement. (It can be the same function.) The function that returns a value must have that value used by the calling function. One function must use a reference argument that is modified in the called function and then used in the calling function. Do not use any global variables. Using a while or do-while loop, read the input, calculate the area, and print the output until the user decides to quit. Ask the user after printing the output if he/she wants to continue. After the user indicates he/she wants to quit, print a closing message. Print the valid geometric shape codes as a "menu". Prompt the user for a valid geometric shape. Do not continue the program until a valid value is entered. The program will only calculate area for a square, a circle, or a rectangle. You may use the following codes for the shapes: C for Circle, S for Square, R for Rectangle. Make sure the information the user sees in the prompt explains clearly what the expected values are. Allow the user to enter the code in lower or upper case. That is, both c and C should be acceptable entries for circle. If the user wants the area of a square calculated, prompt for the length of one side. Calculate area with the formula of area = length * length. If the user wants the area of a circle calculated, prompt for the circle's radius. Calculate area with the formula of area = PI * radius * radius. If the user wants the area of a rectangle calculated, prompt for the rectangle's length and width. Calculate area with the formula of area = length* width. Use a symbolic constant for PI and set its initial value to 3.14159. Print the calculated area to a precision of 2 numbers after the decimal point. You may not use any global variables except for symbolic constants. ![]() ![]() ![]() ![]() ![]() |
|||
|
#12
|
|||
|
|||
Re: Two or more data types in declaration errorQuote:
This what I have so far and cannot get it to loop properly if an invalid input is entered. CPP / C++ / C Code:
|
Recent GIDBlog
Running Linux Programs at Boot Time by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compiling C btrieve programs in VS 2005 | emanresu | C Programming Language | 1 | 16-Nov-2009 03:19 |
| Error C2143: syntax error : missing ';' before '.' | kiranpreddy05 | MS Visual C++ / MFC Forum | 1 | 05-Nov-2009 07:39 |
| Memory leak when nothing is happening... How can I even debug this ? | Algar | MS Visual C++ / MFC Forum | 10 | 19-Nov-2007 07:17 |
| Major newbie problem | cynack | MS Visual C++ / MFC Forum | 1 | 08-Apr-2007 11:25 |
| Help with syntax errors | PeteGallo | C Programming Language | 7 | 08-Aug-2005 20:30 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The