Help with loop or maybe something else IDK

Hello,
I am trying to make a program that has to main functions Input & Output each with its own code to complete the tasks. At the moment I am attempting to work on the Input portion first.
The entire code seems to be working fine. It is when the second while statement is activated that the issues start. It gets stuck in the while loop, Im not really sure whow to explain the issues, But you can try the program out yourself.

THIS program is supposed to store info into a file and output info from said file. I dont have a PC I can write c++ with so I am doing this online "CodeChef"


Also the way its going it looks like I have to write a lot to accommodate for the commands if you know a better way to get around this please also let me know :)
1
2
3
4
5
6
7
while (second != "New Company" && second != "Update Job" && second != "Update Job")
Also:
if (second == "New Company")
   cout << "Your typed New Company" << endl;
  if (second == "New Job")
   cout << "You Typed New Job" << endl;
AS YOU CAN SEE THIS WILL KEEP GOING FOR EACH COMMAND



Here is What I have so far. I also tried using or instead of &&, and or fails every time. The first && cant be or because it will fail.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <string>

using namespace std;

int main() 
{

int a = 1;
string first, second;

cout << "What would you like to do? Please type \"Input\" or \"Output\"" << endl;
cin >> first; 

while (first != "Input" && first != "Output")
  {
  cout << "Please type \"Input\" or \"Output\"" << endl;
  cin >> first;
  }  

//Input Function beyond this point
  
if (first == "Input")
 {
  cout << "List of commands: New Company, New Job, Update Job, there are a lot more commands" << endl;
  cin >> second;
  
  while (second != "New Company" && second != "Update Job" && second != "Update Job")
     {
       cout << "Please type one of the listed commands " << a <<endl;
       cin >> second;
       a++;
     }
  if (second == "New Company")
   cout << "Your typed New Company" << endl;
  if (second == "New Job")
   cout << "You Typed New Job" << endl;
 }
  
// Output Function Beyond this point    
else if (first == "Output")
  cout << "You typed Output" << endl; 
  
    
	return 0;
}



IGNORE IGNORE IGNORE IGNOREIGNORE IGNOREIGNORE IGNOREIGNORE IGNOREIGNORE IGNOREIGNORE IGNOREIGNORE IGNOREIGNORE IGNOREIGNORE IGNOREIGNORE IGNOREIGNORE IGNORE
#include <iostream>
#include <string>

using namespace std;

int main()
{

int a = 1;
string first, second;

cout << "What would you like to do? Please type \"Input\" or \"Output\"" << endl;
cin >> first;

while (first != "Input" && first != "Output")
{
cout << "Please type \"Input\" or \"Output\"" << endl;
cin >> first;
}

//Input Function beyond this point

if (first == "Input")
{
cout << "List of commands: New Company, New Job, Update Job, there are a lot more commands" << endl;
cin >> second;

switch (second)
{
case ""
}

}

// Output Function Beyond this point
else if (first == "Output")
cout << "You typed Output" << endl;


return 0;
}
Last edited on
Topic archived. No new replies allowed.