cell phone code issue

Hello All,

I have been working on this for two nights. I need to ask a user for the month by name and how many minutes they used in that month. My code has to recognize if the user imputed too many minutes for that month.

MY Problem: When I compile my code, the first prompt ask " Please enter your plan" that woks right, but on the second prompt when I ask " Please enter month" and I enter 'May' for example my default initiates and the program closes.

What can I use to have the program recognize the month name and the month hours?

any pointers would help

Thanks in advance

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
 
[code]  #include "stdafx.h"
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>


using namespace std;


int main()


{


	[code]
	char letter;
	char month;

	long double minuts_used;
	double total_A;
	double total_B;
	double total_C;


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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 const int january = 744 * 60,
              february = 672 * 60,
	          march = 744 * 60,
	          april = 720 * 60,
	          may = 744 * 60,
	          june = 720 * 60,
	          july = 744 * 60,
	          august = 744 * 60,
 	          september = 720 * 60,
	          october = 744 * 60,
	          november = 720 * 60,
	          december = 744 * 60;
	

	total_A = 39.99; // cost of plan  A
	total_B = 59.99; // cost of plan  B
 	total_C = 69.99; // cost of plan  C

	// Welcome output display

	cout << " Welcome to over your Budget Mobile" << endl;
	cout << " " << endl << endl;
	cout << " Plan options" << endl;
	cout << " A = 39.99 with 450min/$0.45per min " << endl;
	cout << " B = 59.99 with 900min/$0.40per min" << endl;
	cout << " C = 69.99 with ulimited min" << endl;


    do
	{
	// letter validation

	cout << " " <<endl;
	cout << " Please enter your plan type ";
	cout << " " << endl;
    cout << " " << endl;
	cin >> letter;
	}while(letter != 'A' && letter != 'B' && letter != 'C' && letter != 'a' && letter != 'b' && letter != 'c');
		


   // month 

	cout << " Please enter month" << endl;
	cin >> month;


	// amount of minuts used 
	
	cout << " How many minutes did you use?" << endl;
	cin >> minuts_used;

	  
 // discards negetive input

		if (minuts_used <= 0){
	    cout << " invalid amount" << endl;
	    return 0;
     	}

	cout << setprecision(30) << endl;

	

		// Calculations '

	cout <<  setprecision(2) << fixed << showpoint << endl;
	
	switch (letter)
	{
	case  'a':	  
	case  'A':
		
			if (minuts_used <= 450 && month >= 44640){
				cout << " Your plan A monthly total is " << "$" << 39.99 << endl;
			}
			else if ( minuts_used >= 451 && month <= 44640){
				cout << " Your monthly total is " << "$" << (minuts_used - 450) * .45 + total_A ;
				cout << " " << endl;
				cout << " " << endl;
			
			if ( minuts_used >= 495&& month <= 44640)
				cout << " You could save " << "$" << (minuts_used - 450) * .45 + total_A - 59.99 << " by switching to plan B" << endl;
				cout << " " << endl;
			
			if ( minuts_used >= 517 && month <= 44640)
				cout << " You could save " << "$" << (minuts_used - 450) * .45 + total_A - 69.99 << " by switching to plan C" << endl;
				cout << " " << endl;
			}
		
	 break;
			
	default:{
		cout << " invalid entry" << endl;}
	
		break;
	
[
Last edited on
Please fix your code so its between code tags - http://www.cplusplus.com/articles/jEywvCM9/

Also. What do you need help with, whats the problem? tell us more, are you getting errors? is it not outputting what? in that case what is outputting.
TarikNeaj- Thanks for pointing in the right direction, as far as, asking questions.
I think the problem is that, month looks like this - char month;

Thats a character, it means it only takes a character. 'May' Is not a character. You want to use string for anything thats more than one character -

string month;
Okay That works..

Now I just need to figure out how to get the case switch to recognize too many minutes in a month.

Thanks again,
New to this but learning
Topic archived. No new replies allowed.