Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

how would you do 29 and 30 with the class fraction File Edit Format Bun Options Window Help class Fraction: 7.1 Classes and Objects293 numerator-0

how would you do 29 and 30 with the class fraction

image text in transcribed

File Edit Format Bun Options Window Help class Fraction: 7.1 Classes and Objects293 numerator-0 denominator-1 29. Convert a Decimal to a Fraction Write s program that converts a decimal number to an equivalent fruction. See Fig. 7.7. Use the class Fraction created in Exercise 27 def init (self, numerator, denominator): zateea positive decinai nusber 1ess an : 375 Converted to fraction: 3/8 self.numerator-numerator self-denominator = denominator FIGURE 7.7 Possible outcome of Exercise 29. def gcd (self, a, b) 30. Add Fractions Write program that alds two fractions and displays their sum if a>b: reduced to lowest terms See Fis. 7.8. Use the class Fraction crested in Exercise 7 Ner smaller b bigger -a else: tirst fraction Enter denondnator of f smaller -a bigger-b Enter denoninato r of second fraction: 4 un: 11/12 while (bigger): FIGURE 7.8 Possible outcome of Exercise 30. smaller, bigger-bigger, smaller bigger 31. Earnings Write program that requests an hourly worker's name, hours worked, return smaller and hourly wagn, and then caleulstes his or her week's pwy The program should coneain a class named Wages with instance variables for a worker's name, hours worked, and hourly wag, and a method named fatyFor Week. See Fig 7.9. Note: Fletal lww requires that hourly employees be paid "time-anda-half" for work in excess of 40 hours in week def reduceFraction (self): gcd= self.gcd (self.numerator, self.denominator) self.numerator -gcod self.denominator-ged ntor grade on qui : 9 Enter grade on quiz 2: 10 nter grade on qui 3: S Enter grade on quiz 4: 8 def display (self) Enter person's ntor ber or hours workea:45 Enter hourly wage: 20 Pay ror A11e? $950.00 print ("Eraction: ", int (self.numerator),"/ ", int (self.denominator)) ntor grade on quiz s: 10 Enter grade on quiz 6 10 guizaerage: 9.4 FIBURE 7.9 Possible outcome of Exercise31. FIBURE 7.1D Posile outcome of Exercise 32. fractionFraction (100,20) fraction.reduceFraction ( fraction.display ) 32. Quiz Grades An instructor gives six quizzes during a semester with quiz grades 0 through 10, and drops the lowest grade. Write program to find the verage of the remaining five grades. The program should use a class named Quizzes that has an File Edit Format Bun Options Window Help class Fraction: 7.1 Classes and Objects293 numerator-0 denominator-1 29. Convert a Decimal to a Fraction Write s program that converts a decimal number to an equivalent fruction. See Fig. 7.7. Use the class Fraction created in Exercise 27 def init (self, numerator, denominator): zateea positive decinai nusber 1ess an : 375 Converted to fraction: 3/8 self.numerator-numerator self-denominator = denominator FIGURE 7.7 Possible outcome of Exercise 29. def gcd (self, a, b) 30. Add Fractions Write program that alds two fractions and displays their sum if a>b: reduced to lowest terms See Fis. 7.8. Use the class Fraction crested in Exercise 7 Ner smaller b bigger -a else: tirst fraction Enter denondnator of f smaller -a bigger-b Enter denoninato r of second fraction: 4 un: 11/12 while (bigger): FIGURE 7.8 Possible outcome of Exercise 30. smaller, bigger-bigger, smaller bigger 31. Earnings Write program that requests an hourly worker's name, hours worked, return smaller and hourly wagn, and then caleulstes his or her week's pwy The program should coneain a class named Wages with instance variables for a worker's name, hours worked, and hourly wag, and a method named fatyFor Week. See Fig 7.9. Note: Fletal lww requires that hourly employees be paid "time-anda-half" for work in excess of 40 hours in week def reduceFraction (self): gcd= self.gcd (self.numerator, self.denominator) self.numerator -gcod self.denominator-ged ntor grade on qui : 9 Enter grade on quiz 2: 10 nter grade on qui 3: S Enter grade on quiz 4: 8 def display (self) Enter person's ntor ber or hours workea:45 Enter hourly wage: 20 Pay ror A11e? $950.00 print ("Eraction: ", int (self.numerator),"/ ", int (self.denominator)) ntor grade on quiz s: 10 Enter grade on quiz 6 10 guizaerage: 9.4 FIBURE 7.9 Possible outcome of Exercise31. FIBURE 7.1D Posile outcome of Exercise 32. fractionFraction (100,20) fraction.reduceFraction ( fraction.display ) 32. Quiz Grades An instructor gives six quizzes during a semester with quiz grades 0 through 10, and drops the lowest grade. Write program to find the verage of the remaining five grades. The program should use a class named Quizzes that has an

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students explore these related Databases questions