I am a complete beginner with C++ and I am currently experimenting to improve my skills. After doing Hello world and a calculator programm Im trying my hand at programming a percentage calculator. I have tried loads of different work arounds but I cannot seem to get the program to * the total by 100. It keeps returning the score to 0. Could you please look at the below and tell me where I am going wrong:
#include "stdafx.h"
#include <iostream>
using namespace std;
int ProgramExplanationScore()
{
cout << "Welcome, this programe works out the percentage of your given score by the values that your provide" << endl;
cout << "Please enter your score: " << endl;
int nValue;
cin >> nValue;
return nValue;
}
int EnterTotal()
{
cout << "Please enter the total your wish to compare your score to: " << endl;
int nValue;
cin >> nValue;
return nValue;
}
int DoDivision(int Nx, int Ny)
{
return Nx / Ny;
}
void PrintResult(int TotalResult)
{
cout << "The percentage of your score is: " << TotalResult << endl;
}
int main()
{
int input1 = ProgramExplanationScore();
int input2 = EnterTotal();
int Total = DoDivision(input1, input2);
int TotalResult = Total * 100;
#include "stdafx.h"
#include <iostream>
usingnamespace std;
int ProgramExplanationScore()
{
cout << "Welcome, this programe works out the percentage of your given score by the values that your provide" << endl;
cout << "Please enter your score: " << endl;
int nValue;
cin >> nValue;
return nValue;
}
int EnterTotal()
{
cout << "Please enter the total your wish to compare your score to: " << endl;
int nValue;
cin >> nValue;
return nValue;
}
int DoDivision(int Nx, int Ny)
{
int ToBeReturned = Nx/Ny
return ToBeReturned;
}
void PrintResult(int TotalResult)
{
cout << "The percentage of your score is: " << TotalResult << endl;
}
int main()
{
int input1 = ProgramExplanationScore();
int input2 = EnterTotal();
int Total = DoDivision(input1, input2);
int TotalResult = Total * 100;
PrintResult(TotalResult);
}
Don't have my compiler on me and I am a bit rusty yet that should work.
#include <iostream>
usingnamespace std;
int main()
{
double first, second;
cout << "Welcome, this programe works out the percentage of your given score by the values that your provide" << endl;
cout << "Please enter your score: " << endl;
cin >> first;
cout << "Please enter the total your wish to compare your score to: " << endl;
cin >> second;
cout << "The percentage of your score is: " << (first/second) * 100;
}