What I am stuck on is writing this program to where if the personputs in a value
ID: 3613641 • Letter: W
Question
What I am stuck on is writing this program to where if the personputs in a value outside the range, it will say "Invalid. Please TryAgain." This program works but this is the only thing I can notfigure out. My work is at the bottom and here is the question.Heres the question:
_________________________________________________
Role Permit Type | Sticker Hang tag |
student |$100 $150 |
staff | $200 $300 |
faculty | $300 $450 |
Output Specification
Output the price of the permit for the user with a statement of thefollowing format:
You need to pay $XXX for your parking permit.
where XXX represents the price of the user’s parking permitin dollars.
Sample Run
What role are you? (1=student, 2=staff, 3=faculty)
2
What type of tag do you want? (1=sticker, 2= hang tag)
1
You need to pay $200 for your parking permit.
______________________________________________________________________________
(MY WORK)
#include <stdio.h>
int main(void)
{
int role, permit_type, total;
printf ("what role are you? ( 1 = student, 2 =staff, 3 = faculty) ");
scanf ("%d", &role);
printf ("What type of tag do you want? (1 =sticker, 2 = hang tag) ");
scanf ("%d", &permit_type);
if (role = = 1 && permit_type = = 1)
total = 100;
else if (role = = 1 && permit_type = =2)
total = 150;
else if (role = = 2 && permit_type = =1)
total = 200;
else if (role = = 2 && permit_type = =2)
total = 300;
else if (role = = 3 && permit_type = =1)
total = 300;
else if (role = = 3 && permit_type = =2)
total = 450;
printf ("You need to pay $%d for parkingpermit.", total);
getch ();
return 0;
}
Explanation / Answer
please rate - thanks #include #include int main(void) { int role=0, permit_type=0,total; while(role3) {printf ("what role areyou? ( 1 = student, 2 = staff, 3 = faculty) "); scanf ("%d", &role); if(role3) printf("Invalid. Please try again "); } while(permit_type2) {printf ("Whattype of tag do you want? (1 = sticker, 2 = hang tag) "); scanf ("%d",&permit_type); if(permit_type3) printf("Invalid. Please try again "); } if (role == 1 && permit_type == 1) total = 100; else if (role == 1 && permit_type ==2) total = 150; else if (role == 2 && permit_type ==1) total = 200; else if (role == 2 && permit_type ==2) total = 300; else if (role == 3 && permit_type ==1) total = 300; else if (role == 3 && permit_type ==2) total = 450; printf ("You need to pay $%d for parkingpermit.", total); getch (); return 0; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.