#include "stdafx.h"
#include <iostream>
int subtract(int x, int y)
{
return x - y;
}
int main()
{
using namespace std;
cout << "How much money does the desired item cost?";
int x;
cin >> x;
cout << "How much money do you have currently?";
int y;
cin >> y;
cout << "You need this much more: " << subtract(x, y) << endl;
return 0;
}
#include "stdafx.h"
#include <iostream>
int subtract(int x, int y)
{
return x - y;
}
int main()
{
using namespace std;
cout << "How much money does the desired item cost?";
int x;
cin >> x;
cout << "How much money do you have currently?";
int y;
cin >> y;
cout << "You need this much more: " << subtract(x, y) << endl;
return 0;
}
#include "stdafx.h"
#include <iostream>
int subtract(int x, int y)
{
return x - y;
}
int main()
{
using namespace std;
cout << "How much money does the desired item cost?";
int x;
cin >> x;
cout << "How much money do you have currently?";
int y;
cin >> y;
cout << "You need this much more: " << subtract(x, y) << endl;
return 0;
}
#include <iostream>
using namespace std;
int subtract(int x, int y)
{
return x - y;
}
int main()
{
int quantity = 0;
int price = 0;
int money = 0;
int tempNum;
cout<<"How many items do you have? ";
cin>>quantity;
for(short count = 1; count <= quantity; count++)
{
cout << "How much money does item["<<count<<"] cost?";
cin >> tempNum;
price += tempNum;
}
cout << "How much money do you have currently?";
cin >> money;
cout << "You need this much more: " << subtract(money, price) << endl;
return 0;
}
#include <iostream>
using namespace std;
void main(void)
{
system("cls");
double numbers[2];
char quit[1];
cout << "How much money does the desired item cost?" << endl;
cin >> numbers[0];
cout << "How much money do you have currently?";
cin >> numbers[1];
cout << "You need " <<(numbers[0] - numbers[1] > 0) ? (numbers[0] - numbers[1] + " more dollars.") : (" no more money to buy your item, you have enough!") << "\nWould you like to continue? (y/n):<< endl;
cin.getline(quit, 1);
quit[0] == 'n' ? system("exit") : main();
}
#include "stdafx.h"
#include <iostream>
int main()
{
using namespace std;
cout << "How much money does the desired item cost?";
int x;
cin >> x;
cout << "How much money do you have currently?";
int y;
cin >> y;
if (x > y)
{
cout << "You do not have enough money to buy this item?";
}
else
cout << "You need this much more: " << y - x << endl;
return 0;
}
#include "stdafx.h"
#include <iostream>
int main()
{
using namespace std;
cout << "How much money does the desired item cost?";
int x;
cin >> x;
cout << "How much money do you have currently?";
int y;
cin >> y;
if (x > y)
{
cout << "You do not have enough money to buy this item?";
}
else
cout << "You need this much more: " << y - x << endl;
return 0;
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.