IN PYTHON ONLY
I am looking for 4 columns, Age, Gender, Ideal Age of a Spouse, and the message.
I will have 6 rows in the table, and 4 columns, followed by averages.
Calculate the ideal age of a spouse. Enter either m or f from the keyboard in lower case. You may use string data for the gender. Convert the gender to upper case
Enter an age from the keyboard, probably an integer
You will need prompts telling the user what to enter.
Use an IF statement to determine if the person is a male or female. You do one calculation if the person is a male else you do another calculation if the person is a female.
Use a loop where you enter this data (loop for 1 to 6 or 1 to 7 in Python)
m 28
m 70
m 18
f 32
f 60
f 13
For each set of data, print out the Gender, age, and Ideal Spouse's age, along with the following messages when they apply (the messages will be in the last column):
If a male over 60, print “robbing the cradle.”
If a male under 25, print “too young to be married”
if a female over 60, print “a gold digger”
if a female < 19 print “jail bait”
Plato's formula. A little bit out of date. You will be a gold digger or robbing the cradle if your age is over 40 because back then people only lived to be about 35 or so on the average.
For a male, his ideal spouse’s age is his age/2+7
For a female, her age*2-14
So, inside the loop
1. Input from the keyboard either m or f and an age
2. convert the m or f to upper or upper case
3. enter age from keyboard
4. Use an if to determine if user is a male or female. Use the appropriate syntax for your language. Calculate Ideal age.
5. Print the Gender as “Male” or as “Female”, and the age, and the ideal age you calculated.
6. Then print any matching messages on the same line
7. Accumulate the total idea age of a male spouse and of a female spouse and the count of males and females.
8. When you exit the loop the print the average idea age of a spouse for a male and the average ideal age of a spouse for a female.
if gender=="M"
do male calculation
else
do female calculation
In Python, you will need colons after the if and else.
remember two = signs for comparison
You will need braces for code blocks except in Python where you indent.
import random#import random
list1=[]#tjis is an empty list
total_male=0#nitialize variable to 0
total_female=0
total_ideal_sp_age_female=0
total_ideal_sp_age_male=0
for i in range(6):#loop runs from 1 to 6
list2=["robbing the cradle","a gold digger"]#list2 contains 2 elements this is for age >40
sp_age=0#initialize sp_age =0 and message =""
message=""
gender=input("enter the gender ")#asks user to enter age and convert it to uppercase
gender=gender.upper()
age=int(input("enter age "))#asks user to enter age
if gender=='M':#if gender is male incerement male_count
total_male=total_male+1
sp_age=age/2+7#calculate age and calculate total_ideal_sp_age_male
total_ideal_sp_age_male=total_ideal_sp_age_male+sp_age
if(age>=60):#calculate message based upon their ages
message="robbing the cradle"
elif(age<25):
message=="too young to be married"
else:
if(age>=40):
message=random.choice(list2)
else:
if gender=="F":#if gender is female then increment total_female by 1
total_female=total_female+1
sp_age=age*2-14#calculate sp_age
total_ideal_sp_age_female=total_ideal_sp_age_female+sp_age#calcualte total_ideal_sp_age_female
if(age>=60):#calculate message based upon their ages
message="a gold digger"
elif(age<19):
message=="jail bait"
else:
if(age>=40):
message=random.choice(list2)
list1.append(age)#append age gender sp_age and message to list1
list1.append(gender)
list1.append(sp_age)
list1.append(message)
print(" %5s %5s %10s %10s " % ("Age" ," Gender", " Spouse Age" ," Message") )#prints the statement
for i in range(0,len(list1),4):# for eache element in list1
print(" %5s %5s %10s %23s " % (list1[i],list1[i+1],list1[i+2],list1[i+3]))#prints age gender spouse_age and message
print("TOTAL NUMBER OF MALES----> ",total_male)#prints total_male,total_female,avg(male_spouse) and avg(female_spouse)
print("TOTAL NUMBER OF FEMALES----> ",total_female)
print("AVERAGE AGE OF IDEAL_SPOUSE_MALE----> ",total_ideal_sp_age_male/total_male)
print("AVERAGE AGE OF IDEAL_SPOUSE_FEMALE----> ",total_ideal_sp_age_female/total_female)

IN PYTHON ONLY I am looking for 4 columns, Age, Gender, Ideal Age of a Spouse,...
IN PYTHON ONLY I am looking for 4 columns, Age, Gender, Ideal Age of a Spouse, and the message. I will have 6 rows in the table, and 4 columns, followed by averages. Calculate the ideal age of a spouse. Enter either m or f from the keyboard in lower case. You may use string data for the gender. Convert the gender to upper case Enter an age from the keyboard, probably an integer You will need prompts telling the...
In PYTHON ONLY PLEASE You will use a dictionary in Python You only have string in Python so you have to use a string data type Use a Switch statement.A switch statement is just another way of writing an IF statement. The user will enter f, s, j, or r from the keyboard for freshman, sophomore, junior, or senior. Use character data type for c++. Then you can say something like: char level ='f'; level=toupper(level); You would need a loop...
PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a method that adds all persons Validate all input, not left empty for First Name, Last Name, Gender and numeric for age and throw an exception if it does not validate within the class. Create a Student Class that: Inherits the Person Class Accepts GPA Validate GPA (>= 0 and <= 4.0) and throw exception if it does not validate within the class. Has methods...
Urgent : need to create a java code that has an utput like this ----------------------------------------------------------------------- Gender % Under 30 % 30 or Over % Total -------------------------------------------------------------------------------------------------- Female 44 17 61 Male 23 16 39' -------------------------------------------------------------------------------------------------- Total 67 33 100 The percentages in the table are rounded to the nearest whole number and are percentages of all those who watch the show regularly. Thus, the sum of percentages in the last column of the table must be 100% (ignoring any...
5. The Success Academy is organizing an event for its students. Write a Python program that prompts the user to enter the student's age and gender. The program should then display the day and time for the event registration based on the table below: Gender Registration Monday, 10:00am- 12:00pm Tuesday, 9:00am-12:00pm Wednesday, 9:00am-12:00pm Age Below 10 years old 10 years old and above Male Female Write a Python program that prompts the user to enter his/her monthly weight for the...
Write a program called RentalRate.java which reads in a date of birth, today’s date and a male/female designation from the user, and will then determine the basic daily and weekly rates for rental of an economy class car. Rental rate classes are: Best rate (male drivers, age 33–65 and female drivers, age 30-62)--$40.00per day, $200.00 per week Risk rate 1 (female drivers, age 25–29)–Best rate plus $10.00 per day or best rate plus $55.00 per week. Risk rate 2 (male...
IN PYTHON ONLY!!! Program 2: Design (Pseudocode) and implement (Source Code) a program that asks the user for their height (in inches), weight (in pounds), age and gender. Use loops to validate user input and to continue running for a new user until a sentinel value is entered. Ask them to select their approximate level of exercise each week from the options below, then determine and print their allowed daily caloric intake using their BMR: Female BMR = 655+(4.35 *...
Having trouble with the do while/while loop and the switch
statement. I got some of the switch statement but cant get the
program to repeat itself like it should.What i have so far for my
code is below. Any help is appreciated... i am not sure what I am
doing wrong or what i am missing. I am completely lost on the while
loop and where and how to use it in this scenario.
import java.util.Scanner;
public class sampleforchegg {...
Hello. I am using a Java program, which is console-baed. Here is my question. Thank you. 1-1 Write a Java program, using appropriate methods and parameter passing, that obtains from the user the following items: a person’s age, the person’s gender (male or female), the person’s email address, and the person’s annual salary. The program should continue obtaining these details for as many people as the user wishes. As the data is obtained from the user validate the age to...
I am having trouble with my Python code in this dictionary and
pickle program. Here is my code but it is not running as i am
receiving synthax error on the second line.
class Student:
def__init__(self,id,name,midterm,final):
self.id=id
self.name=name
self.midterm=midterm
self.final=final
def calculate_grade(self):
self.avg=(self.midterm+self.final)/2
if self.avg>=60 and self.avg<=80:
self.g='A'
elif self.avg>80 and self.avg<=100:
self.g='A+'
elif self.avg<60 and self.avg>=40:
self.g='B'
else:
self.g='C'
def getdata(self):
return self.id,self.name.self.midterm,self.final,self.g
CIT101 = {}
CIT101["123"] = Student("123", "smith, john", 78, 86)
CIT101["124"] = Student("124", "tom, alter", 50,...