UP | HOME

Conditionals Project
COP-3223H

Table of Contents

1. Overview

In this project, you will implement the price is right game for three participants, using only the constructs shown in class so far.

2. Repository setup

Log into eustis:

ssh NID@eustis.eecs.ucf.edu

Go to your local repository: Be sure you have already completed the git exercise before attempting this project.

cd ~/cop3223spring26/assignments

Create and enter a directory for the conditionals project:

mkdir conditionals
cd conditionals

You only need to mkdir once to create the directory.

Make sure you are in the right directory

pwd

You should see

/home/net/NID/cop3223spring26/assignments/conditionals

3. Create the price is right program

Make sure you are in the right directory

pwd

You should see

/home/net/NID/cop3223spring26/assignments/conditionals

You will write a program that determines the winners of a price-is-right guessing game for three participants. The winners are those who guessed the closest to the price without going over. Since there are three participants, multiple combinations of participants can win by tie and all participants can lose.

Input: read a price first, then read three guesses (participants 1, 2 and 3, in that order). All are int integers. Do make any prompts, just use scanf("%d", &VARNAME) for whatever VARNAME variable name.

Output: there are several possible results:

  • Every one loses: print "everyone loses\n".
  • One person wins: print the number of the participant that won, i.e., 1, 2, or 3 (don't forget the \n).
  • More than one person wins: print each winning participant's number, in order, one line at a time, i.e., be sure to use the \n.

Use only the C constructs covered in class so far, i.e., inputting and outputting numbers; outputting a string literal; arithmetic operations; declaring, assigning, and using variables; and if statements, if-then-else statements, comparison operators, and Boolean operators.

For example, if we give the following input to our program:

57
55
71
55

the output will be

1
3

Only use the C constructs shown in class so far.

The program must be called conditionals.c and must be in the conditionals directory, i.e., the full path should be

~/cop3223spring26/assignments/conditionals/conditionals.c

Compile and run the program whenever you make changes using

cd ~/cop3223spring26/assignments/conditionals/
gcc -o conditionals conditionals.c
./conditionals

Then enter an integer, hit enter, and observe the output.

4. Submitting your program via git

This assumes you have already setup your repository and that you are still in your hello directory in your repository.

4.1. Add and commit the file

Enter

git add conditionals.c
git commit conditionals.c

Write an appropriate commit message. Remember that you will need to save (Ctrl-x Ctrl-s) then quit (Ctrl-x Ctrl-c) the emacs editor that pops up. If you are having trouble, be sure that you have completed the git project first.

Do not commit the backup file conditionals.c~ nor the conditionals program. Use a .gitignore file to exclude those from the repository, so they won't show up when you type git status.

Then to synchronize the changes to the remote git repository on the grading server:

git push

5. Self-check

5.1. Remove the previous self-check

If you have already run the self-check, you can remove it like this

rm -rf ~/tmp/assignments_selfcheck

Double-check the path carefully to avoid deleting the wrong directory.

5.2. Make a fresh clone of your project

git clone gitolite3@eustis3.eecs.ucf.edu:cop3223/$USER/assignments ~/tmp/assignments_selfcheck

You should see something like

Cloning into '/home/net/NID/tmp/assignments_selfcheck'...

Welcome to eustis.eecs.ucf.edu.

Please use your NID and NID password to log in.

See http://t.cs.ucf.edu/help/eustis  for additional instructions.

remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 16 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (16/16), done.
Resolving deltas: 100% (1/1), done.

If you see

fatal: destination path '/home/net/NID/tmp/assignments_selfcheck already exists and is not an empty directory.

then remove the previous self-check.

5.3. Enter the fresh clone's directory

cd ~/tmp/assignments_selfcheck/conditionals

5.4. Make sure conditionals runs correctly

cd conditionals
gcc -o conditionals conditionals.c
./conditionals

Then run the program as described above.

6. Grading schema

Criterion Points
conditionals.c exists and compiles 1
The program runs correctly, prorated by successful test cases 3
TOTAL 4

Author: Paul Gazzillo

Created: 2026-02-11 Wed 10:13

Validate