|
|
|
#1 (permalink) |
|
New to Overclock.net
|
This is the program I've been working on for my first month of programming. Any tips/Ideas for more additions to this is welcome. Enjoy!!!
Code:
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <time.h>
#include <ctime>
#include <conio.h>
#include <windows.h>
#define MAXWAIT 10000
using std::string;
using namespace std;
int main()
{
//My super Program will contain many different options
float a, b, d, e, f, g;
double number = 0;
string lastname;
string firstname;
int menuchoice;
int h = 0, i = 0, j = 0;
long double k = 1;
double l = 0;
float c;
cout << "Enter Menu Choice Now" << endl;
cout << "1 - Random Stuff" << endl;
cout << "2 - Math stuff" << endl;
cout << "3 - Strings/Words" << endl;
cout << "4 - Simple games" << endl;
cout << "5 - Restart program" << endl; //Currently not working/added
cout << "6 - Exit Program" << endl;
cin >> menuchoice;
system("CLS");
switch(menuchoice)
{
case 1:
{
cout << "Enter a choice of what you want to do" << endl;
cout << "1 - Information Saver" << endl;
cout << "2 - Basic Crackme" << endl;
cout << "3 - Print out source code of the program(pretty cool ehh)" << endl;
cout << "4 - Use system time" << endl; //Currently not added
system("CLS");
cin >> j;
if (j == 1) //Information Saver
{
cout << "Please choose from one of the following options" << endl;
cout << "1 - List the current information you have" << endl;
cout << "2 - Add New Information" << endl;
cout << "3 - Erase the current information" << endl;
cout << "4 - Exit program" << endl;
cin >> h;
system("CLS");
if (h == 1)
{
char str[25600];
std::ifstream in("Information.txt");
while(!in.eof())
{
in.getline(str, 25600);
cout << str << endl;
}
in.close();
break;
}
if (h == 2)
{
char s[1100];
std::ifstream in("Information.txt");
std::ofstream os("Information.txt", ios_base::app);
cout << "Enter your first name" << endl;
cin >> firstname;
cout << "Enter your last name" << endl;
cin >> lastname;
cout << "Enter your phone number" << endl;
cin >> s;
os << "First Name:" << firstname << endl;
os << "Last Name:" << lastname << endl;
os << "Phone Number:" << s << endl;
cout << "How much do you weigh" << endl;
cin >> s;
os << "Weight:" << s << endl;
cout << "How tall are you(In Inches)" << endl;
cin >> s;
os << "Height(In Inches):" << s << endl;
cout << "What nickname do you have" << endl;
cin >> firstname;
os << "Nickname:" << firstname << endl;
cout << "How old are you(Years)" << endl;
cin >> s;
os << "Age:" << s << endl;
cout << "Hair color" << endl;
cin >> lastname;
os << "Hair Color:" << lastname << endl;
cout << "Eye Color" << endl;
cin >> lastname;
os << "Eye Color:" << lastname << endl;
cout << "Do you particapate in any sports if so which ones" << endl;
cin >> lastname;
os << "Sports:" << lastname << endl;
cout << "When were you born" << endl;
cin >> s;
os << "Birthday:" << s << endl;
cout << "Your Address (Format like so Address,City,State,Country)" << endl;
cin >> s;
os << "Address:" << s << endl;
cout << "Are you a girl or boy" << endl;
cin >> s;
os << "Sex:" << s << endl;
cout << "What is your birth city (Address,City,State,Country)" << endl;
cin >> s;
os << "Birthcity:" << s << endl;
cout << "Do you want to save your bank account information" << endl;
cout << "1 - Yes" << endl;
cout << "2 - No" << endl;
cin >> j;
if (j == 1)
{
cout << "What bank do you go through" << endl;
cin >> lastname;
os << "Bank name:" << lastname << endl;
cout << "What is your bank account number" << endl;
cin >> s;
os << "Bank account number:" << s << endl;
cout << "What is your security code (format like so 1234)" << endl;
cin >> s;
os << "Security Code:" << s << endl;
}
if ( (j >= 2) && (j <= 0) )
{
break;
}
cout << "Do you want to save your Credit Card Info?" << endl;
cout << "1 - Yes" << endl;
cout << "2 - No" << endl;
cin >> j;
if (j == 1)
{
cout << "Enter brand name now(example Visa,Mastercard,etc)" << endl;
cin >> lastname;
os << "Credit Card Brand:" << lastname << endl;
cout << "Enter Card Number now (format 1111-2222-3333-4444)" << endl;
cin >> s;
os << "Credit Card Number:" << s << endl;
cout << "Enter security number now (format like this 111)" << endl;
cin >> s;
os << "Security Number:" << endl;
break;
}
if ( (j >= 2) && (j <= 0) )
{
break;
}
cout << "Do you know your social security number" << endl;
cout << "1 - Yes" << endl;
cout << "2 - No" << endl;
cin >> j;
if (j == 1)
{
cout << "Enter Social Security Number (Like this 457-55-5462)" << endl;
cin >> s;
os << "Social Security:" << s << endl << endl;
break;
}
if (j == 2)
{
break;
}
if ( (j >= 3) && (j <= 0) )
{
break;
}
break;
}
if (h == 3)
{
cout << "Are you 100% sure you want to delete the saved information?" << endl;
cout << "1 - Yes" << endl;
cout << "2 - No" << endl;
cin >> j;
if (j == 1)
{
remove("Information.txt");
break;
}
if ( (j >=2) && (j <= 0) )
{
break;
}
}
if (h == 4)
{
break;
}
}
if (j == 2) //Basic Crackme
{
cout << "Enter the correct password now" << endl;
cin >> a;
if (a == 1337)
cout << "Good work you found the correct password" << endl;
else
cout << "Please try again" << endl;
break;
}
if (j == 3)
{
char str[25600];
std::ifstream in("Main.cpp");
while(!in.eof())
{
in.getline(str, 25600);
cout << str << endl;
}
in.close();
break;
}
if (j == 4) //Currently Empty
{
}
}
case 2:
{
cout << "Shotgunner 101's calculator" << endl;
cout << "Menu" << endl;
cout << "1 - For Addition" << endl; //Complete
cout << "2 - For Subtraction" << endl; //Complete
cout << "3 - For Multiplication" << endl; //Complete
cout << "4 - For Division" << endl; //Complete
cout << "5 - Cat and Dog years convertor" << endl; //Complete
cout << "6 - Cubing" << endl; //Half done
cout << "7 - Square root" << endl; //Currently working :)
cout << "8 - Fibinochi Sequence" << endl; //Complete
cout << "9 - Weight on other planets" << endl; //Complete
cout << "10 - Determine how much time something will take out of your life" << endl; //Complete
cout << "11 - Determine how many much time is in a certain ammount of days" << endl; //Complete
cout << "12 - Determine how many hours it will take to travel a certain distance" << endl;
cout << "13 - Currency Convertor" << endl;
cout << "14 - Greatest common divisor" << endl;
cin >> c;
system("CLS");
if ( (c >= 0) && (c <= 15) )
{
if (c == 1) //Addition
{
cout << "Enter first number now" << endl;
cin >> a;
cout << "Enter second number now" << endl;
cin >> b;
d = a + b;
cout << "Answer is:" << d << endl;
}
if (c == 2) //Subtraction
{
cout << "Enter first number now" << endl;
cin >> a;
cout << "Enter second number now" << endl;
cin >> b;
d = a - b;
cout << "Answer for subtraction:" << d << endl;
break;
}
if (c == 3) //Multiplication
{
cout << "Enter first number now" << endl;
cin >> a;
cout << "Enter second number now" << endl;
cin >> b;
d = a * b;
cout << "Answer for multiplication:" << d << endl;
break;
}
if (c == 4) //Division
{
cout << "Enter first number now" << endl;
cin >> a;
cout << "Enter second number now" << endl;
cin >> b;
if ( (a >= 1) && (b >= 1) )
{
d = a / b;
cout << "Answer for division:" << d << endl << endl;
}
if ( (a <= 0) || (b <= 0) )
{
cout << endl << "0 IS NOT A VALID INPUT" << endl;
break;
}
break;
}
if (c == 5) //Human to Cat and Dog years Calculator
{
cout << "1 - Human to Dog years convertor" << endl;
cout << "2 - Human to Cat years convertor" << endl;
d = 0;
cin >> d;
if (d == 1)
{
cout << "Enter your age" << endl;
d = 0;
cin >> d;
a = 10.5;
b = 4;
if (d > 3)
{
c = d - 2;
e = a * 2;
g = b * c;
f = g + e;
cout << "Dogs Age:" << f << endl;
}
if (d == 2)
{
e = a * 2;
cout << "Dogs Age:" << e << endl;
}
if (d == 1)
{
cout << "Dogs Age:" << a << endl;
}
if (d < 1)
{
cout << "Dog can't be 0 years old please enter a number from 1+" << endl;
}
if (a > 0)
{
break;
}
}
if (d == 2)
{
cout << "Enter your age" << endl;
cin >> d;
a = 15;
b = 9;
c = 4;
f = d - 2;
e = a + b;
g = f * c;
f = g + e;
if (d > 2)
{
cout << "Cats age:" << f << endl;
break;
}
if (d == 2)
{
e = a + b;
cout << "Cats Age:" << e << endl;
break;
}
if (d == 1)
{
cout << "Cats Age:" << a << endl;
break;
}
if (d < 1)
{
cout << "Can cannot be 0 years old" << endl;
break;
}
}
if ( (d <= 0) && (d >= 3) )
{
cout << "Invalid option" << endl;
break;
}
}
if (c == 6) //Cubing and Cube roots
{
cout << "Do you want the cube root or to cube something" << endl;
cout << "1 - Cubing" << endl;
cout << "2 - Cube root(Disabled needs further development)" << endl;
cin >> j;
if (j == 1)
{
cout << "Enter the number you want cubed" << endl;
cin >> a; //Cubing is basicly Number * Number * Number * Number = Answer
b = a;
c = a * b;
a = c * b;
cout << "Answer:" << a << endl;
break;
}
if (j == 2)
{
cout << "Enter the number to get the cube root of" << endl;
cin >> a;
b = a;
c = a / b;
cout << "Answer:" << c << endl;
break;
}
if ( (j <= 0) && (j >= 3) )
{
break;
}
}
if (c == 7) //Square root
{
cout << "Enter a number to get the square root of" << endl;
cin >> a;
c = sqrt (a);
cout << "Answer is: " << c << endl;
break;
}
if (c == 8) //Fibinochi Sequence
{
cout << "Fibinoci Sequence will be saved to txt file" << endl;
std::ofstream os("Fibinoci_Sequence.txt");
h = 0;
while (h < 100)
{
h++;
l = number + k;
number = k + l;
os << " " << l << endl;
os << " " << number << endl;
k = number + l;
os << " " << k << endl;
}
if (h >= 99)
{
break;
}
}
if (c == 9) //Weight on other planets
{
cout << "What planet do you want to compare your weight on earth with" << endl;
cout << "1 - The moonn2 - Jupitern3 - Marsn4 - Mercuryn5 - Venusn6 - Saturnn7 - Pluton8 - Uranusn9 - Neptunen";
cin >> a;
system("CLS");
if (a == 1)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 0.165;
cout << "Your weight is:" << l << endl;
}
if (a == 2)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 2.355;
cout << "Your weight is:" << l << endl;
}
if (a == 3)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 0.375;
cout << "Your weight is:" << l << endl;
}
if (a == 4)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 0.375;
cout << "Your weight is:" << l << endl;
}
if (a == 5)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 0.905;
cout << "Your weight is:" << l << endl;
}
if (a == 6)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 0.915;
cout << "Your weight is:" << l << endl;
}
if (a == 7)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 0.059;
cout << "Your weight is:" << l << endl;
}
if (a == 8)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 0.885;
cout << "Your weight is:" << l << endl;
}
if (a == 9)
{
cout << "What is your current weight" << endl;
cin >> b;
l = b * 1.12;
cout << "Your weight is:" << l << endl;
}
break;
}
if (c == 10) //Determine how much time somethign will take out of your life
{
cout << "Enter the years you think you will live" << endl;
cin >> a;
cout << "Enter the time in minutes it takes you to do this a day(if done more than once a day add them together)" << endl;
cin >> b;
c = b * 365;
d = a * c;
c = 0;
c = d / 60;
d = 0;
d = c / 24;
c = 0;
c = d / 365;
cout << "You spent:" << c << " - Years" << endl;
break;
}
if (c == 11) //Determine seconds,minutes,and hours in a certain ammount of days
{
cout << "Please enter a choice now" << endl;
cout << "1 - Seconds" << endl;
cout << "2 - Minutes" << endl;
cout << "3 - Hours" << endl;
cout << "4 - Days" << endl;
cin >> a;
system("CLS");
b = 60;
c = 60;
d = 24;
a = 0;
if (a == 1)
{
cout << "Enter how many days you want to see how many seconds would be in them" << endl;
cin >> h;
i = h * d;
h = 0;
h = i * c;
i = 0;
i = h * b;
cout << "Answer:" << i << " seconds" << endl;
break;
}
if (a == 2)
{
cout << "Enter how many days you want to see how many minutes would be in them" << endl;
cin >> h;
i = h * d;
h = 0;
h = i * c;
cout << "Answer:" << h << " minutes" << endl;
break;
}
if (c == 12) //Determine time to travel a certain distance
{
cout << "Please enter the amount of miles" << endl;
cin >> a;
cout << "Please enter the speed to travel at" << endl;
cin >> b;
system("CLS");
h = a / b;
d = h * 60;
menuchoice = 0;
cout << "Please enter a choice" << endl;
cout << "Choice one - Hours" << endl;
cout << "Choice two - Minutes" << endl;
cout << "Choice three - Seconds" << endl;
cout << "Choice four - Hours,Minutes, and Seconds" << endl;
cin >> menuchoice;
system("CLS");
if (menuchoice == 1) //Hours
{
cout << "" << h << " Hours" << endl;
}
if (menuchoice == 2) //Minutes
{
cout << "" << d << " Minutes" << endl;
}
if (menuchoice == 3) //Seconds
{
i = d * 60;
cout << "" << i << " Seconds" << endl;
}
if (menuchoice == 4)
{
h = a / b;
d = h * 60;
i = d * 60;
if (h >= 1)
{
cout << "Hours: " << h << endl;
cout << "Minutes: " << d << endl;
cout << "Seconds: " << i << endl;
}
}
if (c == 13)
{
cout << "Enter a choice of what currency's to convert between" << endl;
cout << "1 - USA - American Money" << endl;
cout << "2 - Euro's - Europe's Money" << endl;
cout << "3 - Pound's - United Kingdom" << endl;
cout << "4 - Canada Dollars" << endl;
cout << "5 - Audie's - Australia Dollars" << endl;
cout << "6 - Yen - Japan's Currency" << endl;
cout << "7 - Rupee's - India's Currency" << endl;
cout << "8 - New Zealand Dollars" << endl;
cout << "9 - Franc's - Switzerland" << endl;
cout << "10 - Rand - South Africa" << endl;
cout << "11 - Afghani's - Afghanistan's currency" << endl;
cout << "12 - Leke - Albania" << endl;
cout << "13 - Dinar's - Algeria" << endl;
cout << "14 - Peso's - Argentina" << endl;
cout << "15 - Schilling's - Austria" << endl;
cout << "16 - Bahama's Dollars" << endl;
cout << "18 - Dirham's - Morocco" << endl;
cout << "19 - Guilder's - Netherlands" << endl;
cout << "20 - New Zealand Dollars" << endl;
cout << "21 - Kroner - Norway" << endl;
cout << "22 - Rial's - Oman" << endl;
cout << "24 - Ounce's - Palladium" << endl;
cout << "25 - Sole's - Peru Nuevos" << endl;
cout << "26 - Peso's - Phillippines" << endl;
cout << "27 - Zlotych - Poland" << endl;
cout << "28 - Escudo's - Portugal" << endl;
cout << "29 - Riyal's - Qatar" << endl;
system("CLS");
}
if (c == 14) //Not working for some reason
{
cout << "Enter first number: ";
cin >> a;
cout << "Enter second number: ";
cin >> b;
while (a != b)
{
if (a > b)
a -= b;
else
b -= a;
}
cout << "The Greatest common divisior is " << a;
}
break;
}
}
}
case 3:
{
cout << "Enter a choice now" << endl;
cout << "1 - Combine your first and last name" << endl;
cout << "2 - Determine if the first or second word you enter is longer" << endl;
cin >> j;
if (j == 1) //Combine your first and Last name into 1 string
{
string s;
string s2;
cout << "Enter Your First Name now" << endl;
cin >> s;
cout << "Enter You're Second Name Now" << endl;
cin >> s2;
cout << "Your name is: " << s << " " << s2 << endl;
if (s >= s2)
{
break;
}
if (s2 <= s)
{
break;
}
}
if (j == 2) //Determine which word is longer and which is shorter
{
double z, x = 0;
string s;
string s2;
cout << "Enter A Word Now" << endl;
cin >> s;
cout << "Enter You're Second Word Now" << endl;
cin >> s2;
l = s.length();
h = s2.length();
if (l < h)
{
z = h - l;
cout << "First word is shorter by:" << z << endl;
}
if (l > h)
{
z = l - h;
cout << "Second word is shorter by:" << z << endl;
}
break;
}
}
case 4: //Game section
{
a = 0;
cout << "Choice one - Rock, Paper, Scissors" << endl;
cout << "Choice two - Random Dice Rolls" << endl;
cin >> a;
if (a == 1)
{
//These constants define our upper
//and our lower bounds. The random numbers
//will always be between 1 and 6, inclusive.
const int LOW = 1;
const int HIGH = 3;
//Variables to hold random values
//for the first and the second die on
//each roll.
int Random;
//Declare variable to hold seconds on clock.
time_t seconds;
//Get value from system clock and
//place in seconds variable.
time(&seconds);
//Convert seconds to a unsigned
//integer.
srand((unsigned int) seconds);
//Get random number
Random = rand() % (HIGH - LOW + 1) + LOW;
//Output first roll results.
cout << "You got: ";
if (Random == 1)
{
cout << "Rock" << endl;
}
if (Random == 2)
{
cout << "Paper" << endl;
}
if (Random == 3)
{
cout << "Scissors" << endl;
}
}
if (a == 2)
{
//These constants define our upper
//and our lower bounds. The random numbers
//will always be between 1 and 6, inclusive.
const int LOW = 1;
const int HIGH = 6;
//Variables to hold random values
//for the first and the second die on
//each roll.
int first_die, sec_die;
//Declare variable to hold seconds on clock.
time_t seconds;
//Get value from system clock and
//place in seconds variable.
time(&seconds);
//Convert seconds to a unsigned
//integer.
srand((unsigned int) seconds);
//Get first and second random numbers.
first_die = rand() % (HIGH - LOW + 1) + LOW;
sec_die = rand() % (HIGH - LOW + 1) + LOW;
//Output first roll results.
cout << "Your roll is (" << first_die << ", " << sec_die << "}" << endl << endl;
//Get two new random values.
first_die = rand() % (HIGH - LOW + 1) + LOW;
sec_die = rand() % (HIGH - LOW + 1) + LOW;
//Output second roll results.
cout << "My roll is (" << first_die << ", " << sec_die << "}" << endl << endl; //Orgional source http://www.cprogramming.com/tutorial/random.html
}
case 5:
{
}
case 6:
{
cout << "Exiting Program now....." << endl; // Exits the program
break;
}
default:
{
cout << "You have entered a invalid option" << endl; //Detects a option other than the allowed ones and closes program
break;
}
}
}
}
system("PAUSE");
return 0;
}
Last edited by rubendodge : 05-27-08 at 04:08 PM. |
|
|
|
|
|
#2 (permalink) | |||||||||||||
|
PC Gamer
|
so what kind of application is it
__________________
|
|||||||||||||
|
|
|
|
#3 (permalink) | |||||||||||||
|
Going Crazy...
|
ah yes....the good old days of c++ programming class
![]()
__________________
"If you think education is expensive, try ignorance" Folding for OCN under eollis Folding: Help save a life! Need a .iso of Vista x64? PM me.
|
|||||||||||||
|
|
|
|
#4 (permalink) | ||||||||||||||
|
Security Sleuth
|
Holy crap.
Looks like a heck of a lot of work! Good job. Im jealous =)
__________________
Quote:
Proud Member of the Linux Gaming CommunityI am your friend.
|
||||||||||||||
|
|
|
|
|
#5 (permalink) | ||||||||||||
|
Programmer
|
It's a console c++ program with a lot of little things put together as one.
__________________
|
||||||||||||
|
|
|
|
|
#6 (permalink) |
|
New to Overclock.net
|
Yeah its just a bunch of miselanius stuff that I added at the requests of friends and people I knew. Anyways yeah it was alot of work. Especially when I was trying to find out how switch statements would work along with floats and doubles lol. Any more ideas would be welcome
![]() |
|
|
|
|
|
#7 (permalink) | |||||||||||||
|
WaterCooler
|
Mmmm, ...latin!
Looks good though! If I could read it and make sense, that would probably not be a good thing. ![]()
__________________
Future WOFT Hopeful! If you see a Clinic running around in your game, chances are it's me! Say hello!
|
|||||||||||||
|
|
|
|
|
#8 (permalink) | |||||||||||||
|
PC Gamer
|
Nice, but you should post a compiled version because most people here aren't programmers.
__________________
[CS:S Gun Game (ADMIN)] [My CPU-Z] [FAQ - How to make a portable USB charger] [OCN Wallpapers] [OCN Wallpapers 2] [OCN Wallpapers 3]
|
|||||||||||||
|
|
|
|
#9 (permalink) | |||||||||||||
|
The head boob
|
Yeah, I have absolutely NO clue what that says. Looks cool though. Looks like oober 1337 haxorz attempts!!!
__________________
Buy this awesome 939 mobo!!! Quote:
¡¡¡ʍʇɟ qn1ɔ uoıʇɐıɔǝɹddɐ 939 ʇǝʞɔos ǝɥʇ
|
|||||||||||||
|
|
|
|
#10 (permalink) | ||||||||||||||
|
Mile High Club
Join Date: Jul 2006
Location: Intel Fabrication Lab
Posts: 6,672
Rep: 621
![]() ![]() ![]() ![]() ![]() ![]() Unique Rep: 353
Trader Rating: 2
|
Looks like a simple converter. Nice though....
__________________
My Vantage Score Quote:
|
||||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|