943,925 Members | Top Members by Rank

Ad:
Jun 21st, 2009
0

hi 2 all the programmers and programmers 2 be

Expand Post »
hey all, am a student of the University of Trinidad and Tobago. Am doing Computer Engineering - programming dip-bsc then masters- major in cryptgy...
any hows. am fascinated bout programming. if theres a code i have to write, i wouldnt 4 a sec leavt it until i get it to run...
i really love programming also i like to do web page design...

well i really came on here to be a part of the programmers forum- taughts and to share ideas....
i am seeking a greater help and understanding in programming -
C++ and java and netbeans...
so i hope to start interacting with u guys soon,,,,,,,
Similar Threads
Reputation Points: 18
Solved Threads: 0
Newbie Poster
jessejamesjjr is offline Offline
14 posts
since Jun 2009
Jun 21st, 2009
0

Re: hi 2 all the programmers and programmers 2 be

@ d moment, am doing sum reading up on "SWITCHES" and am not sure if am doing the code properly.. so i could share the problem and share my code with u guys.. i wood love to
and if u can suggest any help i wwo greatly appreaciate it....
thanks

Write a program to solve the following problem. DO NOT USE AN IF-ELSE CASCADE.

Calculate the fine to be paid on a speeding ticket. If the automobile speed is less than 50 km/hr, there is no fine. If the speed is between 50 and 60 km/hr, the fine is $15. If the speed is between 60 and 70 km/hr, the fine is $30. If the speed is between 70 and 80 km/hr, the fine is $60. Finally, if the speed is over 80 km/hr, the fine is $150.
Print out the speed and the fine, or the words “no fine” if there is no fine


my codes....
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>

int main(int nNumbersofArgs,char*pszArgs[])
{
int speed;
int Letter;
int a, b, c, d, e;

cout<<"Enter the speed of the automobile"<<endl;
cin>>speed;

cout<<"The following are speeds that are categorized"<<endl<<endl;
cout<<"a = speed is <50 Km/hr"<<endl;
cout<<"b = speed is >50 and <=60 Km/hr"<<endl;
cout<<"c = speed is >60 and <=70 Km/hr"<<endl;
cout<<"d = speed is >70 and <=80 Km/hr"<<endl;
cout<<"e = speed is >80 Km/hr"<<endl<<endl;

a = speed <50;
b = speed >50 && speed <=60;
c = speed >60 && speed <=70;
d = speed >70 && speed <80;
e = speed >80;

cout<<"Enter the Letter of the category that the speed of the automobile is in; ";
cin>>Letter;

switch (speed)
{
case 'A': case 'a':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and there is No Fine"<<endl;
break;
case 'B': case 'b':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and the Fine is $15.00 "<<endl;
break;
case 'C': case 'c':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and the Fine is $30.00"<<endl;
break;
case 'D': case 'd':
cout<<"Speed is " ;
cout<<speed;
cout<< " Kn/hr and the Fine is $60.00"<<endl;
break;
case 'E': case 'e':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and the Fine is $150.00"<<endl;
break;
defalt:
cout<<"Invalid Speed";
cout<<endl;
}

system("PAUSE");
return 0;
}

any suggestions as to wats wrong?? cause am not sure if am doing the SWITCH correct!!!!! thanks in advance
Reputation Points: 18
Solved Threads: 0
Newbie Poster
jessejamesjjr is offline Offline
14 posts
since Jun 2009
Jun 21st, 2009
0

Re: hi 2 all the programmers and programmers 2 be

I will study first the codes you have given, I can't post a relevant reply for now. I will just post it later.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
certficationmx is offline Offline
18 posts
since Jun 2009
Jun 21st, 2009
0

Re: hi 2 all the programmers and programmers 2 be

ok thanks alot look 4ward to ur help cause am still reading but am not sure if am doing the switch correct!!
Reputation Points: 18
Solved Threads: 0
Newbie Poster
jessejamesjjr is offline Offline
14 posts
since Jun 2009
Jun 22nd, 2009
0

Re: hi 2 all the programmers and programmers 2 be

hey guys thanks alot 4 ur time i figured it out....
i was jus missing out main (void)
so heres d code now and it works corectly...

#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
int speed;
char Letter;
int a, b, c, d, e;

cout<<"Enter the speed of the automobile"<<endl;
cin>>speed;

cout<<"The following are speeds that are categorized"<<endl<<endl;
cout<<"a = speed is <50 Km/hr"<<endl;
cout<<"b = speed is >50 and <=60 Km/hr"<<endl;
cout<<"c = speed is >60 and <=70 Km/hr"<<endl;
cout<<"d = speed is >70 and <=80 Km/hr"<<endl;
cout<<"e = speed is >80 Km/hr"<<endl<<endl;

a = speed <50;
b = speed >50 && speed <=60;
c = speed >60 && speed <=70;
d = speed >70 && speed <80;
e = speed >80;


cout<<"Enter the Letter of the category that the speed of the automobile is in; ";
cin>>Letter;

switch (Letter)
{

case 'A': case 'a':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and there is No Fine"<<endl;
break;
case 'B': case 'b':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and the Fine is $15.00 "<<endl;
break;
case 'C':case 'c':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and the Fine is $30.00"<<endl;
break;
case 'D': case'd':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and the Fine is $60.00"<<endl;
break;
case 'E': case 'e':
cout<<"Speed is " ;
cout<<speed;
cout<< " Km/hr and the Fine is $150.00"<<endl;
break;
}

system("PAUSE");
return 0;
}
Reputation Points: 18
Solved Threads: 0
Newbie Poster
jessejamesjjr is offline Offline
14 posts
since Jun 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Community Introductions Forum Timeline: hi, everybody.
Next Thread in Community Introductions Forum Timeline: Hie Guys





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC