Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C++ Programming assignement due tomorrow! Stuck!

Options
  • 20-01-2011 4:27pm
    #1
    Registered Users Posts: 130 ✭✭


    Yo guys, as the thread title says i've a 30% programming assignment due tomorrow and i'm stuck like i dunno what!

    basically the assignment is -

    Students are out picking fruit and get a price per fruit that's picked,
    lemons €0.05,
    oranges €0.04,
    grapefruits €0.03,
    limes €0.03.

    We've to design a C++ program to read personal details of each students (minimum 5 people) (name, college and date of birth are the personal details) and the amount of each picked by the students.

    The program should run until the operator desides for it to stop and it should do an on screen summary report containing the totals picked of each, total wage, and most the picked fruit. Also a bonus is paid to the student which picks the most fruit..

    I've devised an algorithm for this, was wondering what you guys think/help with this would be greatly appreciated.


    Algorithm -

    total_lemons=0
    total_oranges=0
    total_grapefruits=0
    total_limes=0
    total_wages=0
    most_picked=0
    payslip=0
    While loop is running
    {
    Payslip=payslip+1
    Input name, college, dob
    Input lemons,oranges,grapefruits,limes
    fruits_student=lemons+oranges+grapefruits+limes
    if fruits_student>bonus bonus_student=name
    bonus_college=college
    bonus_dob=dob
    total_lemons=lemons+total_lemons
    total_oranges=oranges+total_oranges
    total_grapefruits=grapefruits+total_grapefruits
    total_limes=limes+total_limes

    amont_lemons==lemons*0.05
    amount_oranges= oranges*0.04
    amount_grapefruits= grapefruits*0.03
    amount_limes= limes*0.03
    wages_student=amount_oranges+amount_lemons+amount_grapefruits+amount_limes
    total_wages=wages_student+total_wages


    Display

    Payslip, Name, college,dob, lemons, oranges, grapefruits, limes,
    Lemons*0.05, oranges*0.04,grapefruits*0.03,limes*0.03, Wages_student
    Finish Loop
    }

    If total_lemons>most_picked most_picked=total_lemons
    If total_oranges>most_picked most_picked=total_oranges
    If total_grapefruits>most_picked most_picked=total_grapefruits
    If total_limes>most_picked most_picked=total_limes

    Display
    Bonus_student, bonus_college,bonus_dob,total_lemons,total_oranges,total_grapefruits,
    Total_limes,total_wages,most_picked




    __

    That's what I have so far, haven't wrote any of the actual code yet, waiting to see if this algorithm is accurate or not.

    Thanks, kev.


Comments

  • Closed Accounts Posts: 147 ✭✭OVERTONE69


    The design could use some work. I mean it was pretty difficult to understand. the algortihm seems fine to me in how your calculating the amount of fruit. but the student who pikcs it doesnt seem to be taken into account. why not have

    an array of class students,

    each student has a number of fruits.

    While boolean pick another fruit == true.

    pick a number in the array ( a student)

    pick a fruit, then loop back to ask the user do they want another fruit.


  • Registered Users Posts: 1,657 ✭✭✭komodosp


    if fruits_student>bonus bonus_student=name
    bonus_college=college
    bonus_dob=dob
    I presume all of these are within the IF statement?

    i.e.
    if fruits_student > bonus {
    bonus_student = name
    bonus_college = college
    bonus_dob = dob
    bonus = fruits_student
    }

    (You left out that last line in bold - without it, the last student entered is always going to get the bonus!)
    This doesn't cover you if two students are joint winners of the bonus, BTW


Advertisement