Help with big program!!

So we have been given step by step directions to build a program in preparation for our final. The broad description of the program can be seen here http://www.cplusplus.com/forum/general/156346
I do not need help building the entire program, as this other user is requesting, however I am having trouble with certain steps within the program. Here is the what I have thus far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;

const int flexibility_factor = 0.1725;

int main()
{   
    int i;   
   float x, y, z;
    char type;
    int num_characters;

cout << "Enter the number of characters to create:\n";

   while (true)
{
   cin >> num_characters;
   if (num_characters < 1)
      cout << "Enter the number of characters to create:\n";
     else
      break;
}


Here are the next few instructions that I have gotten stuck on...

Instruction
(Box 9)
Write the start of a for loop that:
Iterates num_characters times
Do NOT write the body of the for loop
Use the integer variable i as your iterator. It has already been declared for you.
You are finished with this block when you type your opening brace '{'

Instruction
(Box 10)
Now you are inside of your for loop
Do NOT prompt the user
Input from the user the type of character and store this into your type variable
Input from the user the value x, y, and z in that order and store into your x, y, and z variables

Instruction
(Box 11)
Now you have good values in type, x, y, and z
Write a switch statement that checks the value of type
If type is A, add half the value of x to the value of y.
If type is B, add double the value of z to the value of x.
If type is C, add 33% of the value of y to the value of z.
If type is not A, B, or C, set the value of z to the average of x, y, and z
Last edited on
I have solved box 9!! Still having complications finishing it out

1
2
for(i=1; i <=num_characters; i++)
{

Does anyone know how I would input the type of character and value for x,y, and z within my for loop function?
Or how to build the switch statement?
Good luck getting a response here man. :/
Been trying all day to get a little help.
1
2
3
4
5
6
7
8
9
10
std::cin >> type >> x >> y >> z;
switch( type ){
case 'A': //...
   break;
case 'B': //...
   break;
case 'C': //...
   break;
default; //...
}
Ne555,
Thanks for the reply. Just to be clear, all I would need to do would be to add in the equations behind the colon for them to fit into the program correctly?

For example... Case 'A' : (.5*x)+y;
yes, but (.5*x)+y; does not have any effect.
you could assign it to a variable, or output the result
how would I output the result of the four lines? Im pretty sure based upon the question I would have to do that
Have a look at:

www.cplusplus.com/doc/tutorial/basic_io/
Topic archived. No new replies allowed.