Computer Programming Homework Question

I'm a college student fighting an uphill battle with his Computer programming in C++ homework. I'm not looking for someone to do it for me, just a push in the right direction. Not really sure where to tackle this one to start...

//

This problem studies functions. A text file contains player scores at cooking competition. There are three judges and each scores the food presentation on a scale of 1 to 10. The lowest and highest scores are weighted one half of the middle score.

Input: File cooking.txt is available in the COS220 First Class Assignments folder. Each line begins with the full name of the contestant in the format: last,first followed by three scores. You may assume names do not contain blanks. Your code should be able to handle data files of any size. Do not edit the input file. You will be using C++ strings to hold and display names.

Bellows,Ann 9.9 9.5 9.2
Thomas,Carl 8.6 8.9 8.5
Treadwell,Paula 10.0 10.0 9.8
Harrisburg,Karen 9.0 9.1 9.2
Vernon,Mark 8.0 9.0 8.6
Ogdon,Roseanne 10.0 9.9 9.5
Chow,Michelle 9.6 9.6 9.6
Rogers,Jamal 9.9 9.6 9.8
Johnston,Cindy 9.0 8.9 8.8
Waters,James 7.0 7.9 7.6


Functions: Several functions are listed below which are to be used in your program. Do not change the specification of the functions and be sure to honor the POST condition.

void swap (double& v1, double& v2);
// POST: exchange the values in v1 and v2

void sort (double& v1, double& v2, double&v3);
// POST: reorder values such that v1 <= v2 <= v3

double final (double v1, double v2, double v3);
// PRE: v1 <= v2 <= v3
// POST: return the weighted sum: ½ v1 + v2 + ½ v3

string lastName (string fullName);
// PRE: full name in form last,first (ex. Smith,Carl)
// POST: return the last name (ex. Smith)

string firstName (string fullName);
// PRE: full name in form last,first (ex. Smith,Carl)
// POST: return the first name (ex. Carl)
Hi, and welcome to the forums :)

Are you supposed to implement the functions? Or write a program which uses those functions? Or both? :P The assignment-text you provided doesn't really tell us what the program is supposed to do either. In any case, have you written any code so far?
Last edited on
Oh, haha, whoops I forgot to include the output section (copy and pasted below). She wants us to implement any and all of the functions we need in a written program. I haven't written any code so far as I am unsure where to start. Thank you so much for your reply and my apologies for the lack of content.

Output: Display your name followed by a neat chart (using field widths) listing for each contestant the first name followed by the last name, the three scores in ascending order followed by the final score. Under the listing display the first and last name and score of the winner.

Note : You will need to split the full name (ex. Bellows,Ann) into two pieces: Ann and Bellows.
Here's what I have for code right now, I just need how to output everything neatly in a grid as the last part of the question states

// COS220 assignment 6
// Created by Riley Werner on 3/19/14.

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>

using namespace std;

void swap (double& v1, double& v2);
// POST: exchange the values in v1 and v2

void sort (double& v1, double& v2, double&v3);
// POST: reorder values such that v1 <= v2 <= v3

double final (double v1, double v2, double v3);
// PRE: v1 <= v2 <= v3
// POST: return the weighted sum: ½ v1 + v2 + ½ v3

string lastName (string fullName);
// PRE: full name in form last,first (ex. Smith,Carl)
// POST: return the last name (ex. Smith)

string firstName (string fullName);
// PRE: full name in form last,first (ex. Smith,Carl)
// POST: return the first name (ex. Carl)


int main ( )
{
//Variables
string fullname;
string lastname;
string firstname;
string winnerfirstname;
string winnerlastname;
double v1;
double v2;
double v3;
double finalscore=0;
double currentscore;
double winnerscore=0;

//Input
ifstream fin;
fin.open("cooking.txt");

cout.setf (ios::fixed | ios::showpoint| ios::left);
cout.precision (1);


}



Topic archived. No new replies allowed.