473,491 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

can i get my errors correct so that the program runs

2 New Member
/************************************************** *****
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
2 1262
weaknessforcats
9,208 Recognized Expert Moderator Expert
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
1 New Member
Thanks! it helped me!
Apr 16 '18 #3

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

Similar topics

0
1264
by: Ollie | last post by:
I am trying to figure out how a complex program written in python works. I am new to python so looking at the source code directly is not helping me much. As such, I am running the program under...
1
1000
by: George Addison | last post by:
I'm caught in a situation where my app runs absolutely perfectly on my local machine. When I upload to my ISPs server, however, I'm presented with a few errors I have not run into, and have...
2
6263
by: Daz01 | last post by:
Hi all. Ive written a program and there are 2 errors that appear when I try to compile the program. I dont know how to correct them. Any help appreciated. Below are the errors ERROR 1: `cout'...
6
1558
by: André | last post by:
Hi, I made a webform for a survey, with multiple-choice questions. The results of each question is put into a table e.g.: values frequency 1 6 2 3 3 32 4 ...
1
1232
by: Slognog | last post by:
I am writing an app that opens a text file. The code I use works perferctly on my local machine. When I copied the executable to a Win 2000 server, the app causes errors and will not open. Is...
2
1243
Atran
by: Atran | last post by:
Hello: I have two programs (Windows Forms). I want to make the second program runs when I press a button in the first program. So when the user go to run the second program, I want the second...
8
5551
by: Jothishankar | last post by:
Hi, I am new to c#. I am trying to build an application that does backup of files to an external hard disk. My application behaves strangely. When i run the application under debug mode (F5),...
0
1144
by: ajmcello | last post by:
What it does: runs through a file, sorts, and splits it alphabetically into files with words that are equal or less than 200. In this example I'm using the dict file, and I use it several...
1
4951
by: sentimental37 | last post by:
hello everybody, iwant to disable all the keyboard shortcuts while my program runs i.e. when my program runs no one could access internet,open start menu,opent taskmanager, open registry,or...
3
1491
by: aravind12345 | last post by:
I have made a Calculator and i need to add a Clear button but i don't know how to clear the screen in the program can someone tell me how i will be thank full. i have no errors or warnings. This...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.