Click here to Skip to main content
15,923,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: thread's local storage, where is it ? Pin
geo_m13-Feb-05 19:52
geo_m13-Feb-05 19:52 
GeneralPCH error Pin
Ashman13-Feb-05 17:02
Ashman13-Feb-05 17:02 
GeneralCrash after making text box blank. Pin
ELY M.13-Feb-05 16:22
ELY M.13-Feb-05 16:22 
GeneralRe: Crash after making text box blank. Pin
Ashman13-Feb-05 17:05
Ashman13-Feb-05 17:05 
GeneralRe: Crash after making text box blank. Pin
ELY M.13-Feb-05 17:40
ELY M.13-Feb-05 17:40 
GeneralRe: Crash after making text box blank. Pin
Ashman13-Feb-05 18:54
Ashman13-Feb-05 18:54 
GeneralRe: Crash after making text box blank. Pin
David Crow14-Feb-05 3:43
David Crow14-Feb-05 3:43 
Generalswitch statement problem Pin
Member 172911913-Feb-05 13:07
Member 172911913-Feb-05 13:07 
So I'm doing a project for a C++ class. I've written all the code, just gotta check for errors Laugh | :laugh:

Long story short, it's a energy bill calculator. I'm not sure if I need to provide more information than that.
The only errors I'm getting are 'illegal case' errors, and they're all coming from the same place. (where the bill is calcuated)

Since there are 3 possible inputs (in this case, Residential, Commercial, or Industrial) I decided to use a switch statement. Here's the code:

// calculate the bill
switch(type); {
case 'r':
case 'R': bill = PRICE_R + (amount * KWH_R); break;
case 'c':
case 'C': bill = PRICE_C + ((amount - 1000) * KWH_R); break;
default: cout << "Unknown use code!";
}

switch(offpeak) {
case 'peak':
case 'PEAK': peak = PRICE_PEAK + ((amount - 1000) * KWH_PEAK); break;
case 'off':
case 'OFF': off = PRICE_OFF + ((offpeak - 1000) * KWH_OFF); break;
default: cout << "Unknown use code!";


Now, there are no errors for the Industrial park (the section with Peak or Off-peak cases), but there are for the Residential and Commerical parts in the first case. My question is, do I need to declare the R and C to make them valid cases?

Any help is greatly appreciated!
GeneralRe: switch statement problem Pin
Ravi Bhavnani13-Feb-05 14:05
professionalRavi Bhavnani13-Feb-05 14:05 
GeneralRe: switch statement problem Pin
Michael Dunn13-Feb-05 16:00
sitebuilderMichael Dunn13-Feb-05 16:00 
GeneralRe: switch statement problem Pin
namaskaaram13-Feb-05 22:24
namaskaaram13-Feb-05 22:24 
GeneralRe: switch statement problem Pin
Anonymous13-Feb-05 23:00
Anonymous13-Feb-05 23:00 
GeneralRe: switch statement problem Pin
David Crow14-Feb-05 3:48
David Crow14-Feb-05 3:48 
GeneralRe: switch statement problem Pin
Mattias G14-Feb-05 6:13
Mattias G14-Feb-05 6:13 
GeneralRe: switch statement problem Pin
David Crow14-Feb-05 7:14
David Crow14-Feb-05 7:14 
QuestionHow to print the picture in a picture control Pin
dadacncn13-Feb-05 12:36
dadacncn13-Feb-05 12:36 
AnswerRe: How to print the picture in a picture control Pin
ThatsAlok13-Feb-05 22:19
ThatsAlok13-Feb-05 22:19 
GeneralCapturing active 2d sprite Pin
Oskars13-Feb-05 12:03
Oskars13-Feb-05 12:03 
GeneralRe: Capturing active 2d sprite Pin
Bob Ciora14-Feb-05 9:33
Bob Ciora14-Feb-05 9:33 
QuestionAvailable window handles? Pin
tstalzer13-Feb-05 11:30
tstalzer13-Feb-05 11:30 
AnswerRe: Available window handles? Pin
rocky_pulley14-Feb-05 1:20
rocky_pulley14-Feb-05 1:20 
AnswerRe: Available window handles? Pin
Michael Dunn14-Feb-05 7:10
sitebuilderMichael Dunn14-Feb-05 7:10 
Generalextract resouce dialogs to vb Pin
Andy Elmore13-Feb-05 10:54
Andy Elmore13-Feb-05 10:54 
GeneralRe: extract resouce dialogs to vb Pin
Michael P Butler13-Feb-05 10:59
Michael P Butler13-Feb-05 10:59 
GeneralRe: extract resouce dialogs to vb Pin
Andy Elmore13-Feb-05 13:12
Andy Elmore13-Feb-05 13:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.