• Log in or sign up for an account here: https://www.sythe.org/login

I want to make a calculator

SmokeHut

Great men grow tired of contentedness.

$100 USD Donor New
Joined
Aug 17, 2011
Sythe Gold
112
Messages
1,504
Location
United Kingdom
Discord Unique ID
865859811747692554
Discord Username
Okesseril#7961
Gohan has AIDS
Sythe's 10th Anniversary
I specific calculator working under this sort of format.

x,y & z

x = Input from user

y = x*2-z

z = x*2/10

X is an input and Y & Z are outputs generated from the input to X.

I don't know a lot about c++ but is this the right software i should be using?

before you tell me to use Excell I want to mass produce this.
 
You could pretty much use any language to make this.
 
Code:
#include <iostream>
using namespace std;

void calc();
float x, y, z;

int main ()
{
	cout << "Input X: ";                               //output
	cin >> x;                                          //waits for input
	
	z = x*2/10;
	y = x*2-z;                                          

	cout << "Y: " << y << endl << "Z: " << z << endl;  //displays answers
	
	system ("pause");  //Remove if you happen to be compiling this in Linux
	return 0;
}

You could do this in any language you like, the only thing is that your 'y' equation is dependent on the 'z' equation and as C++ is sequential, you need to do your 'z' function first.

Take a look at my programming help thread in my signature if you need more help.
 
Gohan has AIDS
Sythe's 10th Anniversary
I basically want it so that you enter X and automatically y&z are outputs, without the pressing of buttons etc.
 
How do you plan on checking when the input has been entered?

Could you explain the situation a bit more fully, because the practical application of this seems futile.

Although, I do have a feeling you'd be better off doing this in an alternative language. I could make a Java GUI that does this for you in literally 5 minutes if you can just explain it a bit better.
 
Gohan has AIDS
Sythe's 10th Anniversary
Basically I want this

2m26e85.jpg


A calculator for hosts.

works out from the wager x2 then minus the hosts keep ( 10% )

I want it to be similar to this and you add in usernames from both duelers to keep track of them. Like i said in my OP I don't know pretty much anything about programming and am not aware of which language is best.
 
just use javascript for this
 
Chess Master
I'm not sure about the code for c++, but for c you could do this:

Code:
(After all the stdio.h stuff)

main(){
  float x , y , z; 
  
  printf("Please enter x\n");
  scanf("%f" , &x);
  z = x * 2/10
  y = x*2 - z
  printf("Y = %f , Z = %f" , y , z);
}

I'm pretty sure theres going to be a syntax error somewhere, i'm sorta rusty :P
 
Said it was solved, but to be honest, the program can be written in just about any language. Not too difficult. The guy that solved it with Java was probably just more comfortable with Java.
 
I'm not sure about the code for c++, but for c you could do this:

Code:
(After all the stdio.h stuff)

main(){
  float x , y , z; 
  
  printf("Please enter x\n");
  scanf("%f" , &x);
  z = x * 2/10
  y = x*2 - z
  printf("Y = %f , Z = %f" , y , z);
}

I'm pretty sure theres going to be a syntax error somewhere, i'm sorta rusty :P

dont forget the ; behind the equations haha
 
Code:
#include <iostream>
using namespace std;

void calc();
float x, y, z;

int main ()
{
	cout << "Input X: ";                               //output
	cin >> x;                                          //waits for input
	
	z = x*2/10;
	y = x*2-z;                                          

	cout << "Y: " << y << endl << "Z: " << z << endl;  //displays answers
	
	system ("pause");  //Remove if you happen to be compiling this in Linux
	return 0;
}

You could do this in any language you like, the only thing is that your 'y' equation is dependent on the 'z' equation and as C++ is sequential, you need to do your 'z' function first.

Take a look at my programming help thread in my signature if you need more help.

Do not use system("PAUSE"); as it's slow and OS-dependant. Replace it with cin.get(); which carries the same function but faster and doesn't depend on your operating system. Seriously, only use system when you're testing a program or messing around, not in any serious application.

Code:
#include <iostream>

using namespace std;

int main()
{
 	int loop = 0;
 	int x;
 	int y;
	int z;
 	
 	cout << "Calculator" << endl;
 	
 	while (loop !=1) {
		  cout << "Wager = ";
		  cin >> x;
		  z = (x*2)/10;
          y = (x*2)-z;
		  cout << "\nWinner receives = " << y << "." << endl;
		  cout << "You receive = " << z << ".\n" << endl;
    }
    return 0;
}

Compile + run in console. Loops after each input.

Very simply done, some things were declared when they didn't need to be. But as you seem to be incapable of creating a C++ calculator, it's marked out for you.

Result:

4aecc616.png
 
Back
Top