423,311 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,311 IT Pros & Developers. It's quick & easy.

can i get my errors correct so that the program runs

P: 2
/************************************************** *****
CS111 Semester 1 - 2018
Assignment 1
Author: Divkesh Kumar
ID Number: s11157069
Campus: Lautoka
************************************************** *****/

#include <iostream>
const int MAX_SIZE = 1000;
bool check_num (int num){

bool check_variable = true;
if (num > 0)
check_variable = false;


return check_variable;

}
void menu_to_screen(){

std::cout<<"\t************************************ ****************"<<std::endl;
std::cout<<"\t********Curreny Transaction Exchange Menu*********"<<std::endl;
std::cout<<"\n\n\tYour Options: Enter--"<<std::endl;
std::cout<<"\n\t-1 - To convert from Fijian Currency to Vanuatu"<<std::endl;
std::cout<<"\n\t-2 - To convert from Vanuatu to Fijian Currency"<<std::endl;
std::cout<<"\t************************************ ****************"<<std::endl;
}
//funtion used to convert from FJD to Vatu and vice vesar
double convert(float value, int option){
double result = 0;
const double conversion_rate = 51.29920; //conversion rate from online website
if (option == 1)
{
result = value * conversion_rate;
}
else
{
result = value / conversion_rate;
}

return result;
}
int main(){
//opening balance
double O_bal_FJD = 10000;
double O_bal_Vatu = 10000000;
double O_bal_Tala = 1000000;
double transaction_record[MAX_SIZE];
int counter = 0;

menu_to_screen();
float score;
double result1, result2;
int option;


std::cout <<"Options: Enter"<<std::endl;
std::cout <<"1 - to convert from FJD to vatu"<<std::endl;
std::cout <<"2 - to convert from vatu to FJD"<<std::endl;
std::cin >>option;

while(check_num(option) == false){
std::cout <<"Error! please enter correct option:"<<std::endl;
menu_to_screen();
std::cin >>option;
std::cout <<"Enter the value to convert: ";
std::cin >>score;

if (option == 1)
{
result1 = convert(score, option);
O_bal_FJD = O_bal_FJD + score;
O_bal_Vatu = O_bal_Vatu - result1;
transaction_recored[counter] = result1;
counter++;
}
else if (option == 2)
{
result = convert(score, option);
}

std::cout<<"Conversion from FJD to Vatu "<<result<<std::endl;
std::cout<<"FJD Balance "<<O_bal_FJD<<std::endl;
std::cout<<"VATU Balance "<<O_bal_Vatu<<std::endl;

std::cout<<"List of Transactions:"<<std::endl;
for (int 1 =0; 1<counter; 1++){
std::cout<<transaction_record[1]<<std::endl;
cout<<"Do you want to make another conversion? ( Y/N ) :";
cout<<"Goodbye :) "<<endl;

return 0;

}
Apr 15 '18 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,162
Do you know how to use your debugger?

If not, this is an opportunity to learn how to use it. Debugging is an essential skill for a software developer.

At the beginning, just step into the code and verify all the variables have correct values. Then after you step into each line of code, verify the values of the variables remains as expected.
Apr 15 '18 #2

NickEdwards89
P: 2
Thanks! it helped me!
Apr 16 '18 #3

Post your reply

Sign in to post your reply or Sign up for a free account.