When asking for user input program skips two questions.Information below.

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
  string airLine = ""; 
  string destination = ""; 
  string airIso = ""; 
  double tripMiles = 0.0; 
  double tripCost = 0; 
  double totalCost = 0; 
  double totalMiles = 0; 

  cout <<"What airline will you be using?\n";
  getline(cin, airLine);

  cout <<"Enter point of origin and destination\n";
  getline(cin, destination);

  cout <<"Enter airlines ISO code and flight number\n";
  getline(cin, airIso);

  cout<<"Enter miles traveled\n";
  cin >> tripMiles;

  cout<<"Enter cost of ticket\n";
  cin >> tripCost;

  
  
  cout<<"Enter point of origin and destination\n";
  cin >> destination;

  cout<<"Enter airlines ISO code and flight number\n";
  cin >> airIso;

  cout<<"Enter miles traveled\n";
  cin >>tripMiles;

  cout<<"Enter cost of ticket\n";
  cin >>tripCost;
  
  
if((airLine.size() >= 3) && (destination.size() >= 5) && (airIso.size() >= 5)&&(tripMiles >= 100.0) && (tripCost >=10.00))
    {
    cout <<"\nContinue\n";
    }
  else
    {
    cout <<"\nError\n";
    system("pause");
    exit (0);
    
    }
    
    string distance = "";
    double monMex = 0;
    double monCal = 0;
    
    cout <<"\nTotal distance Monterey CAL: " ;
    cin >> distance;
    stringstream(distance) >> monMex;
    
    cout <<"\nTotal distance Monterey MEX: " ;
    cin >> distance;
    stringstream(distance) >> monCal;
    
    cout <<"\nEstimated Cost: " <<monMex/monCal<< endl; 
    



system("pause");
return 0;
}

Last edited on
So, basically what this program needs to do, on 3 separate occasions, is to ask the user for information, once the user submits all the data, the program will then do a simple check of this data. For example- the user should input a complete name of an airline, this could be a fictional or a real Airline, but the name has to have more than 3 characters 1
1
2
2:cout <<"What airline will you be using?\n";
getline(cin, airLine);


If the data is "correct" according to our parameters, the program should then save tripMiles; as well as tripCost to totalCost and totalMiles.
Once that is completed, the user will have to answer the questions again, they can use the same or information. the prgram will check again for errors, if none are found we need to add the new values from tripMiles; and tripCost to totalCost and totalMiles.

This process will be repeated once more (users data/ checking for errors). Again taking the new values from tripMiles; and tripCost to totalCost and totalMiles.

the final step will be to average the cost per mile using data from the previous steps.
Last edited on
I can get the program to ask the user for the second input of data but it only asks for the first, second, third question and skips the forth question, this causes the program to give an error due to conditions not being met. If some one would kindly point in the right hat would be appreciated.
Last edited on
Try running the code through a debugger - or put extra cout statements to see whether the values have been read in properly.

You might get more replies if you edit your original post to use code tags, like you have in the others.

HTH - & Have fun !!!
Last edited on
Topic archived. No new replies allowed.