-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4717c8c
commit a224113
Showing
4 changed files
with
314 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//*********************************************** | ||
// This program calculates the user's pay. | ||
// | ||
// By: Jesus Hilario Hernandez | ||
// Last Updated: November 21, 2016 | ||
//*********************************************** | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
double hours, rate, pay; | ||
|
||
// Get the number of hours worked. | ||
cout << "How many hours did you work?"; | ||
cin >> hours; | ||
|
||
// Get the hourly pay rate. | ||
cout << "How much do you get paid per hour?"; | ||
cin >> rate; | ||
|
||
// Calculate the pay. | ||
pay = hours * rate; | ||
|
||
// Display the pay. | ||
cout << "You have earned $" << pay << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//******************************************************* | ||
// This program calculates a customer's available credit. | ||
// | ||
// By: Jesus Hilario Hernandez | ||
// Last Updated: November 21, 2016 | ||
//******************************************************* | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int maxCredit, creditUsed, availableCredit; | ||
|
||
cout << "Enter the customer's maximum credit $"; | ||
cin >> maxCredit; | ||
|
||
cout << "Enter the amount of credit used by the customer $"; | ||
cin >> creditUsed; | ||
|
||
availableCredit = maxCredit - creditUsed; | ||
|
||
cout << "The customer's available credit is $" | ||
<< availableCredit << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <iomanip> | ||
//#include <windows.h> | ||
#include <cstdlib> //for rand and srand | ||
#include <ctime> // for the time | ||
using namespace std; | ||
|
||
|
||
int menu_choice; //declare vaiables | ||
char repeat_menu; | ||
|
||
void Romance(); //function pretotypes | ||
void Fantasy(); | ||
|
||
|
||
int main() | ||
{ | ||
|
||
cout << "This program allows you to find a book you would like to read\n"; | ||
cout << "based on which genre you would prefer to read." << endl; | ||
|
||
do | ||
{ | ||
|
||
cout << "\nChoose a genre from the list below\n" << endl; | ||
|
||
cout << "\n1. Sheet Music " << endl; | ||
cout << "\n2. Romance" << endl; | ||
cout << "\n3. Adventure\n" << endl; | ||
|
||
cin >> menu_choice; | ||
|
||
while (menu_choice != 1 && menu_choice != 2 && menu_choice != 3) | ||
{ | ||
cout << "\nError! Please enter a number from the choices above." << endl; | ||
cin >> menu_choice; | ||
} | ||
|
||
switch (menu_choice) | ||
{ | ||
|
||
case 1: | ||
{ | ||
|
||
} | ||
break; | ||
|
||
case 2: | ||
{ | ||
|
||
cout << "You have chosen romance as your genre." << endl; | ||
Romance(); | ||
|
||
} | ||
break; | ||
|
||
case 3: | ||
{ | ||
Fantasy(); | ||
} | ||
break; | ||
|
||
default: | ||
break; | ||
|
||
} | ||
|
||
cout << "\nWould you like to return to the main menu? (Y/N)" << endl; | ||
|
||
cin >> repeat_menu; | ||
|
||
} while (repeat_menu == 'Y' || repeat_menu == 'y'); | ||
|
||
cout << "\nHave a nice day!" << endl; | ||
return 0; | ||
} | ||
|
||
void Romance() | ||
{ | ||
|
||
} | ||
|
||
void Fantasy() | ||
{ | ||
cout << "\nHere's a list of 3 Adventure books you'd might like to read.\n" << endl; | ||
//Sleep (1000); | ||
|
||
fstream inFile; | ||
const int SIZE = 10; //array size | ||
const int min_value = 0; //min random value | ||
const int max_value = 5; //max random value | ||
|
||
string book[SIZE]; //declare arrays | ||
string author[SIZE]; | ||
string date[SIZE]; | ||
|
||
int count = 0; | ||
int num = 1; | ||
int RNG; //for random generator | ||
|
||
inFile.open ("Booklist2.csv"); //open the file | ||
|
||
if (inFile.fail()) //if file did not open | ||
{ | ||
cout << "Error! Could not open file." << endl; | ||
} | ||
if (inFile) | ||
{ | ||
|
||
while (getline (inFile, book[count], ',')) | ||
{ | ||
getline (inFile, author[count], ','); | ||
getline (inFile, date[count], '\n'); | ||
count++; | ||
} | ||
|
||
cout << "Title" << "\t\t" << setw(25) << "Author" << "\t" << setw(14) << "Date\n" << endl; | ||
|
||
for (int numloop = 0; numloop < 3; numloop++) | ||
{ | ||
//get the system time | ||
unsigned seed = time(0); | ||
//seed the random num generator | ||
srand(seed); | ||
|
||
RNG = (rand() % (max_value - min_value + 1)) + min_value; | ||
cout << num << ". " << book[RNG] << setw(25) << right << author[RNG] << setw(10) << right << date[RNG] << endl << endl; | ||
num++; | ||
|
||
|
||
//Sleep (1000); | ||
} | ||
} | ||
|
||
|
||
inFile.close(); //close the file | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters