Program with two functions

Please help!!

I have to write a c++ program with 2 functions findmax() and getavg(). The function findmax() will print the larger of 2 numbers sent to it and getavg() will calculate the average of 2 numbers sent to it. The main program will ask the user for 2 numbers and then give the user a menu:

Type 'm' to find the max or type 'a' to get the average:

Read in a value from the user and using a switch statement call the appropriate function
We don't do homework
To clarify: This forum will certainly try to help you with homework if there is a specific part you're having trouble with, and you have already attempted the problem yourself. We won't start&finish the homework for you.
I just did your homework with Python!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def findMax(x, y):
    return max(x, y)

def getVg(x, y):
    return (int(x) + int(y)) / 2

first_input = raw_input("Put your number!")
second_input = raw_input("Another one!")

last_input = raw_input("Choose 'm' or 'a'!")

if last_input == "m":
    print findMax(first_input, second_input)
elif last_input == "a":
    print getVg(first_input, second_input)
else:
    print "You typed something wrong!"



Haha!
Last edited on
Thanks yj1214 but I can't turn it in. My professor and I have never elif, first_input, raw_input, etc
Well yeh, thats becuase its written in python and not c++. @yj1214 is just a big dick ignore him.

Listen to the other two comments. Write code yourself, and come post it here and we can slowly help you out.

https://www.youtube.com/playlist?list=PLAE85DE8440AA6B83

Watch some videos here, they're great for the basics.
Topic archived. No new replies allowed.