When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
7 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
@gusty mauve
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
what ive done so far:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
printf("Welcome to the Game, mixedTresures!\n");
// Declaring the variables we require to calculate luckyNumber based off of User input.
int birthYear;
int luckyNumber;
int firstDigit, secondDigit, thirdDigit, fourthDigit;
int randomGreeting;
int initialAwardAmount;
int lifelineUsed = 0;
// Declaring our char variables here, to correctly facilitate the Questions from 1-7 for the Game.
// Question 1
char questionOneResponseUser;
char questionOneCorrectAnswer;
// Question 2
char questionTwoResponseUser;
char questionTwoCorrectAnswer;
// Question 3
char questionThreeResponseUser;
char questionThreeCorrectAnswer;
// Question 4
char questionFourResponseUser;
char questionFourCorrectAnswer;
// Question 5
char questionFiveResponseUser;
char questionFiveCorrectAnswer;
// Question 6
char questionSixResponseUser;
char questionSixCorrectAnswer;
// Question 7
char questionSevenResponseUser;
char questionSevenCorrectAnswer; ```
// User Input for year of birth
printf("\nwhat is your year of birth?\n");
scanf("%d", &birthYear);
luckyNumber = 0;
initialAwardAmount = 100;
// Extract each digit from birth_Year by using these operaotrs:"/", "%"
firstDigit = birthYear / 1000;
secondDigit = (birthYear / 100) % 10;
thirdDigit = (birthYear / 10) % 10;
fourthDigit = birthYear % 10;
// Next, we an add all the individual digits together and store the result in "luckyNumber."
luckyNumber = firstDigit + secondDigit + thirdDigit + fourthDigit;
printf("*************************\n");
printf("Hello, your lucky number is %d\n", luckyNumber);
printf("*************************\n");
// Question 1
printf("1. What is the University of Guelph's mascot?\n");
questionOneCorrectAnswer = 'D';
printf("A. Dragon\n");
printf("B. Centaur\n");
printf("C. Aggie\n");
printf("D. Gryphon\n");
printf("Enter your answer: \n");
scanf(" %c", &questionOneResponseUser);
if (questionOneResponseUser == questionOneCorrectAnswer) {
srand(time(NULL));
randomGreeting = (rand() % 5) + 1;
if (randomGreeting == 1) {
printf("Bravo, you just won $%d\n", initialAwardAmount);
} else if (randomGreeting == 2) {
printf("Congrats, you just won $%d!\n", initialAwardAmount);
} else if (randomGreeting == 3) {
printf("Well done, you just won $%d!\n", initialAwardAmount);
} else if (randomGreeting == 4) {
printf("Very nice, you just won $%d!\n", initialAwardAmount);
} else if (randomGreeting == 5) {
printf("Proud of you, you just won $%d!\n", initialAwardAmount);
}
}
if (questionOneResponseUser != questionOneCorrectAnswer){
printf("Oops - that was incorrect. You still won 0 dollars. Well done. It was fun playing with you\n");
} ```
I realize that if i properly do the first q, then the rest is very doable, so trying to nail the logic with the first portion here
MixedTreasures Game Project