cppnewb's Profile
Reputation: 0
Apprentice
- Group:
- New Members
- Active Posts:
- 13 (0.11 per day)
- Joined:
- 20-January 13
- Profile Views:
- 521
- Last Active:
Jan 23 2013 05:23 AM- Currently:
- Offline
Previous Fields
- Country:
- GB
- OS Preference:
- Windows
- Favorite Browser:
- FireFox
- Favorite Processor:
- AMD
- Favorite Gaming Platform:
- PC
- Your Car:
- Who Cares
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: My code/project dumps
Posted 22 Jan 2013
Figured I'd get this on here as your in the thread
.
I haven't had much time to test it, but division doesn't work nor does modulus as far as I can see...
3)Calculator
#include <cstdlib> #include <iostream> using namespace std; int addition(int x, int y) { int answer = x + y; return answer; } int subtraction(int x, int y) { int answer = x - y; return answer; } int multiplication(int x, int y) { int answer = x * y; return answer; } int division(int x, int y) { int answer = x / y; return answer; } float remainder(int x, int y) { float answer = x % y ; return answer; } int squared(int x) { int y = x; int answer = y * x; return answer; } int cubed(int x) { int y = x; int answer = y * x * x; return answer; } int volume(int x, int y,int z) { //X = length, Y = width, z = height int answer = x * y * z; return answer; } int area(int x, int y) { int answer = multiplication(x,y); return answer; } int main() { int x, y, z, choice; cout << "Welcome to a simple calculator. \n"; cout << "Please follow the on screen instructions \n" "Please enter the appropriate number corresponding to the function you wish to use"; cout << "\t 0: Addition \t 1: Subtraction \t 2: Multiplication \t 3: Division \t 4: Remainder \t 5: Square" "\t 6: Cube \t 7: Volume \t 8: Area"; cin >> choice; switch(choice) { case 0: cout << "and now enter the numbers you wish to add\n"; cin >> x >> y; cout << " is = to" << addition(x, y); break; case 1: cout << "and now enter the numbers you wish to subtract\n"; cin >> x >> y; cout << " is = to " << subtraction(x, y); break; case 2: cout << "2*2 = 5, now what would you like to multiply?"; cin >> x, y; cout << "The probably incorrect answer is " << multiplication(x, y); case 3: cout << "So you wish to divide eh? What ever you do don't enter 0"; cin >> x, y; if(x == 0 || y == 0) { cout << "WHAT HAVE YOU DONE!@!@!"; } else { cout << "Wise, you are. The answer you shall have \t" << division(x, y); } break; case 4: cout << "You want the modulus...I want numbers!\n"; cin >> x, y; cout << "The remainder is " << remainder(x, y); break; case 5: cout << "Nano nano, oh wait what the square is? Sorry could you tell me the number again..\n"; cin >> x; cout << "You mean if you times yourself by yourself you get something different?..\n" << squared(x); break; case 6: cout << "Ahhh young skywalker you wish to obtain the cube? Details I must have\n"; cin >> x; cout << "The cube is now but a shard " << squared(x); break; case 7: cout << "and now enter the length, width and height of the object \n"; cin >> x >> y; cout << "The volume is " << volume(x, y, z); break; case 8: cout << "and now enter width and length to find the area \n"; cin >> x >> y; cout << "The area is " << area(x, y); break; } return 0; } -
In Topic: My code/project dumps
Posted 22 Jan 2013
I'll read that link, thanks. You must be watching me...I'm literally using \t at the moment.....
Just gotta figure out this logic bug in my calculator and that will be up, also probably got
around 5-10 minutes left on the password generator
.
- Nub -
In Topic: My code/project dumps
Posted 22 Jan 2013
Sorry for the double post, I can't seem to find the edit button - can anyone point me in rough position of it?
As I'm going to need it....
2) Basic Currency convertor
/* Basic currency convertor, based on the real conversion rate as of * 22/01/13 7am */ #include <cstdlib> #include <iostream> using namespace std; float gbp2eur(int x) { return x * 1.19; } float gbp2usd(int x) { return x * 1.58; } float gbp2jpy(int x) { return x * 141.28; } float gbp2cad(int x) { return x * 1.57; } float gbp2aud(int x){ return x * 1.50; } int main(int argc, char** argv) { int x, choice; cout << "You will now be presented with a list of options, " " please select the appropriate\n "; cout << "0: GBP to USD \n 1: GBP to EUR \n 2: GBP to CAD \n 3: GBP to AUD\n" " 4: GBP to JPY\n"; cin >> choice; cout << "Now how much do you wish to convert?"; cin >> x; //Could have used if statements....but this is so much more simple switch (choice) { case 0: cout << "No. of GBP: " << x << " Converted to USD: " << gbp2usd(x) << "\n"; break; case 1: cout << "No. of GBP: " << x << " Converted to EUR: " << gbp2eur(x) << "\n"; break; case 2: cout << "No. of GBP: " << x << " Converted to CAD: " << gbp2cad(x) << "\n"; break; case 3: cout << "No. of GBP: " << x << " Converted to AUD: " << gbp2aud(x) << "\n"; break; case 4: cout << "No. of GBP: " << x << " Converted to JPY: " << gbp2jpy(x) << "\n"; break; default: cout << "Whoops some thing went wrong...."; } return 0; }
3)Calculator
4)Random Password Generator
- Nub -
In Topic: My code/project dumps
Posted 21 Jan 2013
.Aaron, on 21 January 2013 - 01:53 AM, said:You may want to have some one move this to the Share Your Project forum. Much better fit.
/>
Ahhh. I actually spent 15 minutes trying to figure out the correct forum, in the end I figured a mod wouldn't begrudge me to much as a newb...
Aphex19, on 21 January 2013 - 03:41 AM, said:Your code seems fine. I guess I could point out two minor things that I would change. Firstly, the string you read in to the variable 'question' isn't used. I'd just use std::cin.get(); with no assignment. Secondly, spelling mistake here; "Your question was *too stupid to proceed", although that's not very important...
Whoops, should have made the necessary changes. I was using the var as a test. That's
massively important considering I was implying the user was stupid! Thanks.
I have a calculator to add to my first post, goes just above the basic addition/subtraction/division/multiplication
. Also have a random password generator to add, for now though sleep - tomorrow I may work on an alarm.
-Nub -
In Topic: cout << hello world
Posted 21 Jan 2013
Ohhh you Mofo! I laughed when I saw the quote because
I knew what was coming lol, I'm going to have to start proof reading my posts.
Little fingers? Try the opposite....
- Nub
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Location:
- London
- Interests:
-
My interests vary greatly, from general security to psychology, programming to attempting to learn new (verbal) languages.
I also love breaking stuff, purposely or otherwise as 97% of the fun comes from fixing them :D.
Oh and gaming, besides that there's tons of things I haven't listed. - Years Programming:
- 4
- Programming Languages:
-
Java
Python ( A little)
C++
Others:
HTML
CSS
PHP (Enough to get by)
JS (Same as above, though I truly hate JS)
Contact Information
- E-mail:
- Private
Friends
|
|


Find Topics
Find Posts
View Reputation Given

|
Comments
cppnewb
21 Jan 2013 - 02:37