First off, I'm a beginner..
I'm basically trying to create a program that will project a soccer teams points for the whole season.
Here are the basics:
Total games: 38
Win: 3 pts
Draw: 1 pt
Loss: 0 pts
My program compiles fine, but inevitably crashes right before the if statement.. Can you please help me figure out why? Thank you!
Code:
#include<stdio.h>
int main(void)
{
float ppg, games_played, games_left, points_earned, pts_proj;
char team_one;
printf("What is the name of the first team?");
scanf("%s", &team_one);
printf("How many games have been played?");
scanf("%f", &games_played);
printf("How many points have been earned?");
scanf("%f", &points_earned);
ppg = points_earned / games_played;
printf("The points per game is %.2f\n", ppg);
if (games_played < 38) {
games_left = 38 - games_played;
pts_proj = games_left * ppg + points_earned;
printf("The predicted finish of %s is %-3.2f\n\n", team_one, pts_proj);
} else if (games_played == 38) {
printf("The season has already ended for %s", team_one);
}
return 0;
}