Alright I have just started using C++ recently so am doing these sort of programs. I am not finished this one yet but there are a few errors I do not know how to fix. Ill list the errors below the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
#include "stdafx.h"
#include <cmath>
using namespace System;
float add_func(float);
float sub_func(float);
float mult_func(float);
float div_func(float);
float end_func(float);
int main(array<System::String ^> ^args)
{
float add1;
float sub1;
float mult1;
float div1;
float x;
float t = 0;
while t = 0;
{
Console::WriteLine("Please Choose an option:\n");
Console::WriteLine("1: Addition\n2: Subtraction\n3: Multiplication\n4: Division\n5: Exit\n");
x = Convert::ToInt16(Console::ReadLine());
if (x > 0 && x < 6)
{
if (x == 1);
{
add1++;
add_func();
}
if (x == 2);
{
sub1++;
sub_func();
}
if (x == 3);
{
mult1++;
mult_func();
}
if (x == 4);
{
div1++;
div_func();
}
if (x == 5);
{
end_func;
}
Console::WriteLine("\n\n\nTimes used:\nAddition:"+add1+"\nSubtraction:"+sub1+"\nMultiplication:"+mult1+"\nDivision:"+div1);
}
}
return 0;
}
float add_func(float)
{
float ax;
float ay;
float an;
Console::WriteLine("Please enter the two numbers you would like added");
Console::WriteLine("First number: ");
ax = Console::ReadLine();
Console::WriteLine("Second number: ");
ay = Console::ReadLine();
an = ax + ay;
Console::WriteLine("The answer is: "+an);
return 0;
}
float sub_func(float)
{
float sx;
float sy;
float sn;
Console::WriteLine("Please enter the two numbers you would like added");
Console::WriteLine("First number: ");
sx = Console::ReadLine();
Console::WriteLine("Second number: ");
sy = Console::ReadLine();
sn = sx - sy;
Console::WriteLine("The answer is: "+sn);
return 0;
}
float mult_func(float)
{
float mx;
float my;
float mn;
Console::WriteLine("Please enter the two numbers you would like multiplied");
Console::WriteLine("First number: ");
mx = Console::ReadLine();
Console::WriteLine("Second number: ");
my = Console::ReadLine();
mn = mx * my;
Console::WriteLine("The answer is: "+mn);
return 0;
}
float div_func(float)
{
float dx;
float dy;
float dn;
Console::WriteLine("Please enter the two numbers you would like divided");
Console::WriteLine("First number: ");
dx = Console::ReadLine();
Console::WriteLine("Second number: ");
dy = Console::ReadLine();
dn = dx / dy;
Console::WriteLine("The answer is: "+dn);
return 0;
}
float end_func(float)
{
return 0;
}
| |
Errors:
Error 1 error C2061: syntax error : identifier 't' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 23
Error 3 error C2660: 'add_func' : function does not take 0 arguments c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 35
Error 5 error C2660: 'sub_func' : function does not take 0 arguments c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 41
Error 7 error C2660: 'mult_func' : function does not take 0 arguments c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 47
Error 9 error C2660: 'div_func' : function does not take 0 arguments c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 53
Error 12 error C2440: '=' : cannot convert from 'System::String ^' to 'float' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 76
Error 13 error C2440: '=' : cannot convert from 'System::String ^' to 'float' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolmi\Cdriolm\Cdriolm.cpp 78
Error 14 error C2440: '=' : cannot convert from 'System::String ^' to 'float' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 94
Error 15 error C2440: '=' : cannot convert from 'System::String ^' to 'float' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 96
Error 16 error C2440: '=' : cannot convert from 'System::String ^' to 'float' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 112
Error 17 error C2440: '=' : cannot convert from 'System::String ^' to 'float' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 114
Error 18 error C2440: '=' : cannot convert from 'System::String ^' to 'float' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 130
Error 19 error C2440: '=' : cannot convert from 'System::String ^' to 'float' c:\Documents and Settings\cdriol\My Documents\Visual Studio 2005\Projects\Cdriolm\Cdriolm\Cdriolm.cpp 132