Question & Answer: Make a report to explain each step in this Dev C++ prog. including introduction,steps of the program , discussion and conclusion :…..

Make a report to explain each step in this Dev C++ prog. including introduction,steps of the program , discussion and conclusion :

#include<iostream>
using namespace std;
int main()
{
double MYR,conv,ch,cont=1;
while(cont!=0)
{
cout<<“1.To Singapore dollar (SGD)n2.To United States Dollar (MYR)n3.To Australia Dollar (AUD)n4.Euro (EUR)n5.To India RupeenEnter choice : “;
cin>>ch;
if(ch>=1 && ch<=5)
{
cout<<“Enter Malaysia Ringgit (MYR) amount : “;
cin>>MYR;
if(MYR!=0)
{
if(ch==1)
conv=MYR*0.32;
else if(ch==2)
conv=MYR*0.23;
else if(ch==3)
conv=MYR*0.29;
else if(ch==4)
conv=MYR*0.20;
else if(ch==5)
conv=MYR*14.89;
cout<<“converted value is : “<< conv <<endl;
}
else if(MYR==0)
cout<<“Enter non-zero value.”;
}
if(ch<1 || ch>5)
cout<<“Wrong choice.n”;
cout<<“Do you want to continue?(1->YES || 0->NO) : “;
cin>>cont;
cout<<“n”;
}
}

Expert Answer

 

Introduction:

This program converts the Malaysia Ringgit (MYR) into the following currency:

1.     Singapore Dollar (SGD).

2.     United States Dollar (USD).

3.     Australia Dollar (AUD).

4.     Euro (EUR).

5.     India Rupee.

Steps and working of the program:

·       The program displays the menu which contains the above currencies and allows the user to choose the currency from the menu.

·       Then, according to the user choice, it converts the MYR into the other country’s currency.

·       The program also uses the while loop for the following reason.

o   If the user wants to convert the MYR into the two or more currencies, then it also allows the user to convert into two or more currencies.

#include<iostream>                              //Line1

using namespace std;                            //Line2

int main()                                      //Line3

{                                               //Line4

double MYR,conv,ch,cont=1;                      //Line5

while(cont!=0)                                  //Line6

{                                               //Line7

cout<<“1.To Singapore dollar (SGD)n2.To United States Dollar (MYR)n3.To Australia Dollar (AUD)n4.Euro (EUR)n5.To India RupeenEnter choice : “;     //Line8

cin>>ch;                                        //Line9

if(ch>=1 && ch<=5)                              //Line10

{                                               //Line11

cout<<“Enter Malaysia Ringgit (MYR) amount : “; //Line12

cin>>MYR;                                       //Line13

if(MYR!=0)                                      //Line14

{                                               //Line15

if(ch==1)                                       //Line16

conv=MYR*0.32;                                  //Line17

else if(ch==2)                                  //Line18

conv=MYR*0.23;                                  //Line19

else if(ch==3)                                  //Line20

conv=MYR*0.29;                                  //Line21

else if(ch==4)                                  //Line22

conv=MYR*0.20;                                  //Line23

else if(ch==5)                                  //Line24

conv=MYR*14.89;                                 //Line25

cout<<“converted value is : “<< conv <<endl;    //Line26

}                                               //Line27

else if(MYR==0)                                 //Line28

cout<<“Enter non-zero value.”;                  //Line29

}                                               //Line30

if(ch<1 || ch>5)                                //Line31

cout<<“Wrong choice.n”;                        //Line32

cout<<“Do you want to continue?(1->YES||0->NO):”; //Line33

cin>>cont;                                      //Line34

cout<<“n”;                                     //Line35

}                                               //Line36

}                                               //Line37

Explanation and discussion step by step:

·       Line1 includes the header file iostream which is used for input/output operations.

·       Line2 of this program uses the namespace std which is used for cin, cout.

·       Main function starts from line number 3.

·       Variables MYR, conv, ch of type double declare at line5 and the variable cont declares and initializes to “1” at line5.

·       While loop starts from line6. It will run till the value of cont becomes 0.

·       Menu displays at line8.

·       Line9 prompts the user to enter the choice and stores the value in the variable ch.

·       Line10 checks the condition whether the user enter the provide the right choice or not. If condition checks whether the value of ch is greater than 1 and less than 5 or not. If choice is not greater than 1 and less than 5, then execution will go at line31.

·       Line13 prompts the user to enter the Malaysia Ringgit (MYR) amount and stores the value into the variable MYR.

·       Line15 checks whether the entered amount is 0 or not. If the entered amount is 0, then execution of the program will go at line28.

·       If the user entered the choice 1, then program converts the MYR into Singapore Dollar by multiplying.32 to MYR and stores the value into conv.

·       If the user entered the choice 2, then program converts the MYR into United States Dollar by multiplying .23 to MYR and stores the value into conv.

·       If the user entered the choice 3, then program converts the MYR into Australia Dollar by multiplying.29 to MYR and stores the value into conv.

·       If the user entered the choice 4, then program converts the MYR into Euro by multiplying .20 to MYR and stores the value into conv.

·       If the user entered the choice 4, then program converts the MYR into Indian Rupee by multiplying14.89 to MYR and stores the value into conv.

·       The converted value displays at line29.

·       Line35 prompts the user whether to continue or not and stores the value into cont.

·       If the value of cont is 1, then the execution of the program will go at line6. Otherwise, the program will terminate.

Conclusion:

Thus, with the help of this program one can easily converts the MRY into other countries currency.

Still stressed from student homework?
Get quality assistance from academic writers!