C++

General chit chat, chin wag, abuse, etc.
Post Reply
No-1
Loyal fan
Posts: 291
Joined: Sun Sep 12, 2004 5:57 am
Location: tdy

Post by No-1 »

Rewrite the following if-else chain using a switch statement:

if (letterGrade == 'A')
cout << " The numerial grade is between 90 and 100\n";
else if (letterGrade == 'B')
cout << "The numerical grade is between 80 and 89.9\n";
else if (letterGrade == 'C')
cout <<"The numerical grade is between 70 and 79.9\n";
else if (letterGrade == 'D')
cout << "How are you going to explain this one?\n";
else
{
cout << " Of course the exam was difficult to do\n";
}

This is what i came up with:

switch (letterGrade)

{
case 'A';
case 'a';
cout <<type stuff in here\n";
case 'B';
case 'b';
cout <<........\n";
case 'C'
case 'c'
cout <<.....\n";
case 'D'
case 'd'
cout <<....\n"

'default';
cout <<........";
}

Where did i go wrong anyone help me? Finals tomorrow :(
Support Outpost@HBTop50<br><a href='http://hbtop50.berserkvision.com/in.php?id=582' target='_blank'>Outpost@HBTop50</a><br>
charlie
Outpost4lyfe
Posts: 3324
Joined: Sun Apr 06, 2003 12:24 am
Location: Mt GOD
Contact:

Post by charlie »

switch(letter_grade)
{
Case A:
cout <<The numerial grade is between 90 and 100\n";
break;
Case B:
cout <<The numerial grade is between 80 and 89.9\n";
break;
Case C:
cout <<The numerial grade is between 70 and 79.9\n";
break;
Case D:
cout <<How are you going to explain your dumbass answer\n";
break;
Default:
cout<<sex me\n";
}
Girlfriends are dedicated hookers.
charlie
Outpost4lyfe
Posts: 3324
Joined: Sun Apr 06, 2003 12:24 am
Location: Mt GOD
Contact:

Post by charlie »

Girlfriends are dedicated hookers.
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

switch (letterGrade)

{
case 'A':
case 'a':
cout << "........";
break;

case 'B':
case 'b':
cout << "........";
break;

case 'C':
case 'c':
cout << "........";
break;

case 'D':
case 'd':
cout << "........";
break;

default:
cout << "........";
break;
}

you write messy code....
charlie
Outpost4lyfe
Posts: 3324
Joined: Sun Apr 06, 2003 12:24 am
Location: Mt GOD
Contact:

Post by charlie »

decrypting your mess was even harder
Girlfriends are dedicated hookers.
Sprint
Spamtastic
Posts: 1000
Joined: Tue Jun 06, 2006 6:59 am
Location: Far from home
Contact:

Post by Sprint »

can i ask wtf is the purpose of that code?? Is it a test i you can code?? if it is lmao
<span style='color:blue'><span style='font-size:19pt;line-height:100%'><u><b>FUCK Helbreath!</b></u></span></span><br><br><span style='color:gray'><a href='http://www2.analystica.com/users/anttu/online/ngd' target='_blank'>ngdnetwork</a> OFFICIAL WEBSITE OF Northern Game Developers. Do visit! (THEY ARE UP!)<br><a href='http://project3d.x.am' target='_blank'>Project3d development forum</a> plz join and discuss,develop,give ideas,feedback. Anything goes as long it helps the project!</span><br><br>Zepto Znote 6625WD: 1.8Ghz dual core, 2GB, 512mb graphics card(dedicated), 160GB HDD<br><img src='http://www.signaturebar.com/uploads/images/10111.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/13229.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/8852.png' border='0' alt='user posted image' />
No-1
Loyal fan
Posts: 291
Joined: Sun Sep 12, 2004 5:57 am
Location: tdy

Post by No-1 »

Thnx for the answers. Its for a final test :D
Support Outpost@HBTop50<br><a href='http://hbtop50.berserkvision.com/in.php?id=582' target='_blank'>Outpost@HBTop50</a><br>
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

bit of an easy question isnt it for a test O.o even i could have answered that.
Orkl
Loyal fan
Posts: 376
Joined: Sat Sep 17, 2005 2:31 pm

Post by Orkl »

charlie wrote: decrypting your mess was even harder
ROFL!
<!--QuoteBegin-crazymnig88+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (crazymnig88)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->by notepad??? it didn't show any code, just show words wif no mean<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd--><br><!--QuoteBegin-charlie+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (charlie)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->he'll probably save it as 600pagebook.bmp<br><br>400gb file plzkthnx<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd-->
Sprint
Spamtastic
Posts: 1000
Joined: Tue Jun 06, 2006 6:59 am
Location: Far from home
Contact:

Post by Sprint »

i must say that even i write more advanced codes than the and i dont even go in any school for coding/comps lol
<span style='color:blue'><span style='font-size:19pt;line-height:100%'><u><b>FUCK Helbreath!</b></u></span></span><br><br><span style='color:gray'><a href='http://www2.analystica.com/users/anttu/online/ngd' target='_blank'>ngdnetwork</a> OFFICIAL WEBSITE OF Northern Game Developers. Do visit! (THEY ARE UP!)<br><a href='http://project3d.x.am' target='_blank'>Project3d development forum</a> plz join and discuss,develop,give ideas,feedback. Anything goes as long it helps the project!</span><br><br>Zepto Znote 6625WD: 1.8Ghz dual core, 2GB, 512mb graphics card(dedicated), 160GB HDD<br><img src='http://www.signaturebar.com/uploads/images/10111.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/13229.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/8852.png' border='0' alt='user posted image' />
SexyBitch
Member
Posts: 199
Joined: Mon Mar 29, 2004 12:17 pm
Location: UK, London
Contact:

Post by SexyBitch »

KLKS wrote: switch (letterGrade)

{
case 'A':
case 'a':
cout << "........";
break;

case 'B':
case 'b':
cout << "........";
break;

case 'C':
case 'c':
cout << "........";
break;

case 'D':
case 'd':
cout << "........";
break;

default:
cout << "........";
break;
}

you write messy code....
KLKS have not seen you around for a while what you up to

Sexy
<img src='http://72.29.68.107/~helbrea/lorraine/S ... itch01.gif' border='0' alt='user posted image' />
Post Reply