HTML interesse |
|
voor school moesten we een rekenmachine in c++ maken, wat ik effe geleend en aangepast heb van barry zijne deze
maar er moet nog effe een functie van worteltrekken en machten in
zover is dit mijn script
#include <iostream.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <iomanip.h>
#include <string.h>
int main()
{
int keuze;
float mach=0, macht;
long num1;
long num2;
char count;
long som;
char yesno;
menu:
cout << "1. Rekenmachine" << endl;
cout << "2. Afsluiten" << endl;
cout << "Maak uw keuze: " << endl;
cout << "--> ";
cin >> keuze;
if(keuze==1)
{
goto calculator;
}
if(keuze==2)
{
goto exit;
}
else
{
cout << endl << "Ongeldige invoer!" << endl;
getch();
goto menu; }
calculator:
cout << "Getal1: ";
cin >> num1;
cout << "Getal2: ";
cin >> num2;
cout << "Berekening (*, +, -, /, macht[m] of Worteltrekken[W]:";
cin >> count;
if(count=='*')
{
som = num1 * num2;
}
if(count=='-')
{
som = num1 - num2;
}
if(count=='/')
{
som = num1 / num2;
}
if(count=='+')
{
som = num1 + num2;
}
if(count=='m')
{
cout << "Macht" << endl;
}
if(count=='w')
{
cout << "WortelTrekken" << endl;
}
cout << "Uitkomst:" << endl;
cout << num1 << " " << count << " " << num2 << " = " << som << endl << endl;
cout << endl << "Wilt u nog een berekening maken?" << endl << "Y/N]: ";
cin >> yesno;
if(yesno=='y')
{
goto calculator;
}
if(yesno=='n')
{
goto menu;
}
else {
goto confirm_calc;
}
confirm_calc:
cout << endl << endl << endl << "Ongeldige invoer!" << endl;
cout << endl << "Wilt u nog een berekening maken?" << endl << "[Y/N]: ";
cin >> yesno;
if(yesno=='y')
{
goto calculator;
}
if(yesno=='n')
{
goto menu;
}
else {
goto confirm_calc;
}
exit:
return 0;
}
#include <iostream.h> #include <windows.h> #include <stdio.h> #include <conio.h> #include <iomanip.h> #include <string.h> int main() { int keuze; float mach=0, macht; long num1; long num2; long som; char yesno; menu: cout << "1. Rekenmachine" << endl; cout << "2. Afsluiten" << endl; cout << "Maak uw keuze: " << endl; cout << "--> "; cin >> keuze; if(keuze==1) { goto calculator; } if(keuze==2) { } else { cout << endl << "Ongeldige invoer!" << endl; getch(); goto menu; } calculator: cout << "Getal1: "; cin >> num1; cout << "Getal2: "; cin >> num2; cout << "Berekening (*, +, -, /, macht[m] of Worteltrekken[W]:"; { som = num1 * num2; } { som = num1 - num2; } { som = num1 / num2; } { som = num1 + num2; } { cout << "Macht" << endl; } { cout << "WortelTrekken" << endl; } cout << "Uitkomst:" << endl; cout << num1 << " " << count << " " << num2 << " = " << som << endl << endl ; cout << endl << "Wilt u nog een berekening maken?" << endl << "Y/N]: "; cin >> yesno; if(yesno=='y') { goto calculator; } if(yesno=='n') { goto menu; } else { goto confirm_calc; } confirm_calc: cout << endl << endl << endl << "Ongeldige invoer!" << endl; cout << endl << "Wilt u nog een berekening maken?" << endl << "[Y/N]: "; cin >> yesno; if(yesno=='y') { goto calculator; } if(yesno=='n') { goto menu; } else { goto confirm_calc; } return 0; }
maar je mag NIET gebruiken maken van de standaard functie sqrt
weet iemand hoe?;-)
|