Ask your own question, for FREE!
Computer Science 12 Online
OpenStudy (anonymous):

need help with these problems i need it written in C++ code, 1. Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch statement to display the Roman number version of that number. Input validation: do not accept a number less than 1 or greater than 10. 2.The area of a rectangle is the rectangle's length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the areas are the same.

OpenStudy (anonymous):

1) #include<istream.h> #include<conio.h> void main() { clrscr; int a; cout<<"Enter a number from 1-10"; cin>>a; if((a>=1)&&(a<=10)) { switch(a) { case 1:cout<<"I"; break; case 2:cout<<"II"; break; case 3:cout<<"III"; break; case 4:cout<<"IV"; break; case 5:cout<<"V"; break; case 6:cout<<"VI"; break; case 7:cout<<"VII"; break; case 8:cout<<"VIII"; break; case 9:cout<<"IX"; break; case 10:cout<<"X"; } } else cout<<"Wrong digit, Enter a number from 1 to 10"; getch(); }

OpenStudy (anonymous):

IF that helps, I'l try doing the second one too :)

OpenStudy (anonymous):

hah i see what my problem was thank you this helped greatly

OpenStudy (anonymous):

solution to problem 2: #include<istream.h> #include<conio.h> void main() { clrscr; int len_rectA; int width_rectA; int len_rectB; int width_rectB; int area_rectA; int area_rectB; cout<<"Enter the lenght of rectangle A"; cin>>len_rectA; cout<<"Enter the width of rectangle A"; cin>>width_rectA cout<<"Enter the lenght of rectangle B"; cin>>len_rectB; cout<<"Enter the width of rectangle B"; cin>>width_rectB area_rectA = len_rectA * width_rectA; area_rectA = len_rectB * width_rectB; if(area_rectA > area_rectB) { cout<<"Rectangle A has a greater area than rectangle B"; } else if(area_rectA < area_rectB) { cout<<"Rectangle B has a greater area than rectangle A"; } else { cout<<"Both rectangles are the same size"; } getch(); }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!