ssgliberty
January 31st, 2012, 02:29 AM
i got board am am taking a c++ class so combined a few projects into one program with somthing i remember from the little bit of java i took. , compile/run program if you want. ( i havnt inserted all the comments yet, the comments are from when i did the assignments)
// Hello_World by Liberty Satonica
// Include Libraries
#include <iostream>
// Use Standerd namespace
using namespace std;
// makes my hello world conversation into a single command.
void Conversation () {
// Declare variables
int Hello;
int Good;
int Cool_Bye;
int Yes;
//print text to screen
cout << "Hello World!" << endl;
cout<< "Press 1 to say hello" << endl;
cin >> Hello;
if (Hello == 1) {
cout << "How are you today?" << endl;
}
cout << "Press 1 to say (good , you?)." << endl;
cin >> Good;
if (Good == 1) {
cout << "Thats great! , I am fine." << endl;
}
cout << "Press 1 to say (Cool , Bye.)." << endl;
cin >> Cool_Bye;
if (Cool_Bye == 1) {
cout << "Goodbye!, I am going to send you to calculator!" << endl;
}
}
// make my calculator program into a single command.
void Calculator ( ) {
// Declare the variables
float Number_1;
float Number_2;
float Result;
int Which_Calculation;
int More = 0;
while (More !=2 ) {
// Give instructions
cout << "Choose a task. Press 1 to add, 2 to subtract, 3 to multiply, and 4 to divide." << endl;
cin >> Which_Calculation;
// Get numbers
cout << "Please enter the first number." << endl;
cin >> Number_1;
cout << "Please enter the second number." << endl;
cin >> Number_2;
if (Which_Calculation == 1) {
// Calculate the result
Result = Number_1 + Number_2;
}
if (Which_Calculation == 2) {
// Calculate the result
Result = Number_1 - Number_2;
}
if (Which_Calculation == 3) {
// Calculate the result
Result = Number_1 * Number_2;
}
if (Which_Calculation == 4) {
// Calculate the result
Result = Number_1 / Number_2;
}
// Print the answer is...
cout << "The answer is..." << endl;
//Print the result
cout << Result << endl;
cout << " Would you like to do more? (Press 1 for yes Or 2 for no)" << endl;
cin >> More;
}
}
void Guess_My_Favorite_Number () {
// Declare the variables
int My_Number;
float Result;
// Give instructions
cout << "Hello! Can you guess Liberty Satonica's Favorite Number?" << endl;
// Try to get the real answer.
cout << "Hint: Dukes Of Hazard Car" << endl;
cin >> My_Number;
if (My_Number == 1969) {
// Calculate the result
cout << "Good Job! You Are Correct!" << endl;
}
if (My_Number > 1969) {
// Calculate the result
cout << "Im sorry , You are incorrect." << endl;
}
if (My_Number < 1969) {
// Calculate the result
cout << "Im sorry , You are incorrect." << endl;
}
}
void main () {
Conversation ();
Calculator () ;
Guess_My_Favorite_Number () ;
system ("pause");
}
// Hello_World by Liberty Satonica
// Include Libraries
#include <iostream>
// Use Standerd namespace
using namespace std;
// makes my hello world conversation into a single command.
void Conversation () {
// Declare variables
int Hello;
int Good;
int Cool_Bye;
int Yes;
//print text to screen
cout << "Hello World!" << endl;
cout<< "Press 1 to say hello" << endl;
cin >> Hello;
if (Hello == 1) {
cout << "How are you today?" << endl;
}
cout << "Press 1 to say (good , you?)." << endl;
cin >> Good;
if (Good == 1) {
cout << "Thats great! , I am fine." << endl;
}
cout << "Press 1 to say (Cool , Bye.)." << endl;
cin >> Cool_Bye;
if (Cool_Bye == 1) {
cout << "Goodbye!, I am going to send you to calculator!" << endl;
}
}
// make my calculator program into a single command.
void Calculator ( ) {
// Declare the variables
float Number_1;
float Number_2;
float Result;
int Which_Calculation;
int More = 0;
while (More !=2 ) {
// Give instructions
cout << "Choose a task. Press 1 to add, 2 to subtract, 3 to multiply, and 4 to divide." << endl;
cin >> Which_Calculation;
// Get numbers
cout << "Please enter the first number." << endl;
cin >> Number_1;
cout << "Please enter the second number." << endl;
cin >> Number_2;
if (Which_Calculation == 1) {
// Calculate the result
Result = Number_1 + Number_2;
}
if (Which_Calculation == 2) {
// Calculate the result
Result = Number_1 - Number_2;
}
if (Which_Calculation == 3) {
// Calculate the result
Result = Number_1 * Number_2;
}
if (Which_Calculation == 4) {
// Calculate the result
Result = Number_1 / Number_2;
}
// Print the answer is...
cout << "The answer is..." << endl;
//Print the result
cout << Result << endl;
cout << " Would you like to do more? (Press 1 for yes Or 2 for no)" << endl;
cin >> More;
}
}
void Guess_My_Favorite_Number () {
// Declare the variables
int My_Number;
float Result;
// Give instructions
cout << "Hello! Can you guess Liberty Satonica's Favorite Number?" << endl;
// Try to get the real answer.
cout << "Hint: Dukes Of Hazard Car" << endl;
cin >> My_Number;
if (My_Number == 1969) {
// Calculate the result
cout << "Good Job! You Are Correct!" << endl;
}
if (My_Number > 1969) {
// Calculate the result
cout << "Im sorry , You are incorrect." << endl;
}
if (My_Number < 1969) {
// Calculate the result
cout << "Im sorry , You are incorrect." << endl;
}
}
void main () {
Conversation ();
Calculator () ;
Guess_My_Favorite_Number () ;
system ("pause");
}