» »

napaka v programu c++

napaka v programu c++

kretze ::

zdravo zanima me če ve kdo zakaj mi zakaj mi program ne deluje pravilno saj ko kliknem d in nastavim neko vredno in potem kliknem(od a do g) mi javi napako da ni v dosegu le-tega??




*/
//knjiznice
#include <iostream>	
#include <stdlib.h>
#include <string> 
using namespace std; 

class account
{
private:
	double balance;
	double intrate;
	double interst;
	int transaction;
public:
	account(double irate = 0.045, double bal = 0.0)
	{
		balance = bal;
		intrate = irate;
		interst = 0;
		transaction = 0;
	}

	void makedeposit(double amouth)
	{
		balance += amouth;
		transaction++;
	}
	void calcinterest()
	{
		interst = balance*intrate;
		balance += interst;
	}
	double getbalance()
	{
		return balance;
	}
	double getinteresr()
	{
		return interst;
	}
	int getTransaction()
	{
		return transaction;
	}
	bool widtraw(double amouth)
	{
		if (balance < amouth)
			return false;
		else
		{
			balance -= amouth;
			transaction++;
			return true;
		}

	}
};

class charRange
{
private:
	char input, lower, uper;
public:
	charRange(char l, char u)
	{
		lower = toupper(l);
		uper = toupper(u);
	}

	char getchar()
	{
		cin.get(input);
		cin.ignore();
		input = toupper(input);
		while (input<lower || input>uper)
		{
			cout << "that is now valid charchter " << endl;
			cout << "enter a value from " << lower;
			cout << " to " << uper << endl;
			cin.get(input);
			cin.ignore();
			input = toupper(input);

		}
		return input;
	}


};


void displayMenu()
{
	cout << "\n                 MENU\n\n";
	cout << "a) display the account balance\n";
	cout << "b) display the number of transaction\n";
	cout << "c) display interesr earned for this period\n";
	cout << "d) make a deposit\n";
	cout << "e) make a withdrawal\n";
	cout << "f) add a interest for this period\n";
	cout << "g) exit the program\n\n";
	cout << "enter your choice";

}
void makedepost(account & acc)
{
	double dolars;
	cout << "enter the amouth of deposit " << endl;
	cin >> dolars;
	acc.makedeposit(dolars);
}
void widtdrawal(account & acc)
{
	double dolars;
	cout << "enter the amoutj of widtdraw " << endl;
	cin >> dolars;
	if (!acc.widtraw(dolars))
		cout << "ERROR tool large\n\n";
}

int main()
{
	account acc;
	charRange input('A', 'G');
	char choice;
	do
	{
		displayMenu();
		choice = input.getchar();
		switch (choice)
		{
		case 'A':
			cout << "the current balace is ";
			cout << acc.getbalance();
			break;

		case 'B':
			cout << "there have been ";
			cout << acc.getTransaction() << "transaction";
			break;

		case 'C':
			cout << "interest warned for this period";
			cout << acc.getinteresr();
			break;
		case 'D':
			makedepost(acc);
			break;
		case 'E':
			widtdrawal(acc);
			break;

		case 'F':
			  acc.calcinterest();
			  cout << "interes added\n";
			  break;
		


		}
		
	} while (choice != 'G');

	system("pause");// da is ogledam rezultate na zaslonu
	return 0;
}

black ice ::

Najprej popravi tipkarske napake, ker tole je grozno brat. Zakaj ne uporabiš cifer namesto črk? Takoj odpade toUpper.


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

[C++] Iskalno drevo implementacija

Oddelek: Programiranje
52308 (1866) eXoo
»

C++ to upper case

Oddelek: Programiranje
5830 (760) boogie_xlr
»

Prikaz programa v windowsih

Oddelek: Programiranje
101268 (1186) s51as
»

[ C ] floating point not loaded !!?

Oddelek: Programiranje
111560 (1493) Fizikalko
»

[C++] Functor za izračun osnovne statistike podatk. strukture (vector,list...)

Oddelek: Programiranje
91490 (1403) Vesoljc

Več podobnih tem