1.
Objective: Write a program that reads from a file a list of course names, letter grades for each course and number of credits each course is worth. The program will read each course name, grade earned and number of credits from the file and print out the course name, grade earned and number of credits for each course to the screen. After the program has read in all of the courses, grades earned and credits, the program should calculate the grade point average based on all of the courses read in by the program.
Notes: Students who receive an “F” grade earn zero credits for the course but the grade is still used as part of the GPA calculation When displaying the GPA, only display up to two decimal points
Sample Input File:A data file named grades.txt will be attached as part of the assignment. It will contain sample course names, grades earned and number of credits attempted. Your program should read this file in as input. Make sure you put this file in the same directory as your project. Below is a sample of the input file.
Jane Doe
Chemistry A 4.0
Calculus B 4.0
History C 3.0
Gym A 1.0
English A 3.0
2.
“Battle Fleet Game”
Background: The Pacific Ocean is a powder keg ripe for explosion with the Imperial Red Fleet (IRF) making trouble by terrorizing the shipping lanes between us and our interests in the Far East. The Pacific Blue Fleet (PBF) needs a capable commander to lead them in this time of peril. You have been selected as the new commander of the United States Pacific Blue Fleet. Reconnaissance units have located the enemy fleet. You job is to engage the enemy fleet and annihilate them completely. The IRF fleet is well equipped and possesses ships that rival your own. They would like nothing more than to send your fleet to the bottom of the ocean. This battle would be decided by the cunning and tactics of the commander.
Mode: The game should have three player modes: player vs. player or player vs. computer or computer vs. computer.
Goal: Strategically place your ships throughout your part of the ocean to keep them away from the enemy. Try and sink the enemy by hitting their ships before they hit you!
Skill Level: When the game is in player vs. computer mode, there should be 3 skills levels. The skill levels are as follows:
Beginner: The computer randomly guesses selects coordinates. No intelligence involved.
Intermediate: The computer will make an educated guess passed on previous hit. For instance, if computer achieved hit, it should check next available coordinate along x coordinate.
Expert: The computer will make an educated guess passed on previous hit. For instance, if computer achieved hit, it should check next available coordinate along x axis and/or y axis.
Ocean Grids: The Pacific Ocean is broken up into two ocean grids: one grid for each fleet. An ocean grid consists of a 10 x 10 grid. Each position on the grid will be represented by a two positive integers that constitutes a XY coordinate.
Ships: There are a total of 5 ships for both the PBF and the IRF respectively. Each fleet has the same complement of ships. The description of the ships is listed below including the number of hits needed to sink a ship:
Aircraft Carrier 5 hits
Battleship – 4 hits
Cruiser – 3 Hits
Destroyer 3 hits
Submarine – 2 Hits
3.
The BCAT Slot Machine Simulation Project
User Story:
As the owner of BCAT Gambling Industries, LLC, I want a slot machine simulation program to project the financial viability of opening up a slot-based casino in Bel Air, MD.
Description:
Write a program to simulate a casino slot machine. The slot machine will accept bets for the following amounts: $1, $5, $10, $20, $50, $100 and $1,000.The program will operate by having the slot machine select a random number (the winning number) at the start of the day and/or after the slot machine pays out a winner. Each time the player pulls the slot handle, he/she will generate a random number. If the player’s number is the same as the winning number, the player will win all or a percentage of the jackpot as illustrated in the payoff table
BCAT Payoff Table - Bet Amount & Payoff (Greater of the two amounts)
$1 .01% of jackpot or $100
$5 .05% of jackpot or $500
$10 1% of jackpot or $1000
$20 2% of jackpot or $2000
$50 5% of jackpot or $5000
$100 10% of jackpot or $10,000
$1000 Total jackpot or $100,000
Assumptions:
• The jackpot starts the day with $10,000 and grows by the amount wagered by the player after each turn (For example, if the jackpot is $20,000 and the players bets $100, the new jackpot will be $20,100.
• The slot will hit (meaning the player wins) 1% of the time.
• There are three random number generators: the winning number for the slot machine, the player’s number and one to determine the wager.
• The amount of money wagered during each play is randomly selected. The amount of money wagered must be one of the following: $1, $5, $10, $20, $50, $100, and $1000. Hint. Use an array store the 7 different bet amounts.
• The simulation will operate for 24 hours straight with the slot machine being played once a minute. This means the slot machine will be played 1,440 times in 24 hours. Use a loop to simulate a player pulling the slot handle.
Definitions:
Amount Won – The amount of money won by the player.
Bet Amount – The amount of money wagered by the player
Jackpot – The total money in the jackpot eligible to be won by the player
Winning Number – The random number that represents the number needed to win
Player’s Number – The random number that is compared to the winning number to determine if the player wins.
Pulling the Slot Handle – the act of getting a new random number that becomes the player’s number
Acceptance Criteria:
• Documented C code that compiles and executes without errors.
• C file and output file submitted to Blackboard without zipping files.
• The program will terminate after the simulated 24 hours is complete and all output is written to a text file. The required output is stated below.
• Every time the slot handle is pulled, the following information is outputted (to a file):
o Amount of the jackpot
o Amount of the current bet
o The winning number
o The players number
• In addition to the information listed above, the following information should be displayed when a player wins:
o The amount of money won by the player
• At the end of the 24 hours, the following information is outputted:
• The amount of money the casino will make/lose because of the slot machine.
• The amount of money made by the slot machine equals the amount of money entered by the player over the 24 hour period – amount of money paid out by the slot
Extra Credit:
Modify your program to simulate a casino operating 10 slot machines
Acceptance Criteria:
• Write one output file per slot machine to illustrate its operations based on the original acceptance criteria
• Write a totals output file to show how much the casino made from each slot machine and the total amount made by the casino from all of the slot machines.
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references.
Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.
1.
#include <stdio.h>
#include <stdlib.h>
typedef struct Student
{
double numCredits;
char fname[20], lname[20];
char class_names[20][20];
char letter_grades[20];
int num_classes;
double class_GPA[20];
double GPA;
}Student;
double gradeValue(double credits, char grade);
int main()
{
FILE *inFile;
char filename[20];
int i;
Student students[100];
int num_students = 0;
errno_t err;
printf("Please enter a file name to read from: ");
scanf_s("%s", filename, 20);
err = fopen_s(&inFile, filename, "r");
if (err == 0)
{
printf("The file 'data2' was opened\n");
}
else
{
printf("The file 'data2' was not opened\n");
}
while (1)
{
char fname[20], lname[20], class_name[20];
char letter = '0';
double credits;
if (fscanf_s(inFile, "%s", fname, _countof(fname)) == EOF)
break;
if (fscanf_s(inFile, "%s", lname, _countof(lname)) == EOF)
break;
if (fscanf_s(inFile, "%s", class_name, _countof(class_name)) == EOF)
break;
while (letter != 'A' && letter != 'B' && letter != 'C' && letter != 'D' && letter != 'F')
letter = fgetc(inFile);
if (fscanf_s(inFile, "%lf", &credits) == EOF)
break;
for (i = 0; i < num_students; i++)
{
This is only a preview of the solution.
Please use the purchase button to see the entire solution.
By purchasing this solution you'll be able to access the following files: