Question

and scientists Using Functions Lab Activity For this exercise, open the recently-updated For Loop Lab Activity that uses the
Task #9: write a new Type 3 function called process Loop re including: years remaining until retirement, year number inde tha
using this code to complete. it python 3.#Display Program Purpose
print("The program will show how much money you will make working a job that gives a inputted percentage increase each year")
#Declaration and Initialization of Variables
userName = "" #Variable to hold user's name
currentYear = 0 #Variable to hold current year input
birthYear = 0 #Variable to hold birth year input
startingSalary = 0 #Variable to hold starting salary input
retirementAge = 0 #Variable to hold retirement age input
remainingYears = 0 #Variable to hold years left to work
salaryIncrease = 0 #Variable to hold increase in yearly salary
i = 0 #Variable i
newSalary = 0 #Variable to hold new salary input
yearsWorked = 0 #Variable to hold years spent working input
netTotal = 0 #Variable to hold total money earned
#Prompt user to input name
userName = input("Please enter your first name: ")
#Prompt user to input the current year
currentYear = int(input("Please enter the current year (xxxx): "))
#Prompt user to input birth year
birthYear = int(input("Please enter your birth year (xxxx): "))
#Prompt user to input starting salary
startingSalary = int(input("Please enter your starting salary(xxxxx): $"))
#Prompt user to input salary increase
salaryIncrease = float(input("Please enter the increase you expect (.xx): "))
#Prompt user to input expected retirement age
while(retirementAge != 62 and retirementAge != 67 and retirementAge != 70):
retirementAge = int(input("Please enter your expected retirement age (62, 67, or 70): "))
#Calculate value of remainingYears variable
remainingYears = retirementAge - (currentYear - birthYear)
#Reinitialize yearsWorked variable to 1
yearsWorked = 1
#Display calculations for first year of work
print(userName, "Estimated remaining years to work: ", remainingYears)
print("Years Worked\tYear\tSalary")
print(yearsWorked, "\t\t", currentYear, "\t $", startingSalary)
#Calculate salary for each year using for loop logic
for i in range(remainingYears):
startingSalary = (startingSalary * salaryIncrease) + startingSalary
yearsWorked = yearsWorked + 1
currentYear = currentYear + 1
netTotal = netTotal + startingSalary
print(yearsWorked, "\t\t", currentYear, "\t", "$", round(startingSalary))
#Display solution of total money earned over lifetime
print("Total net earnings: $", round(netTotal)






0 0
Add a comment Improve this question Transcribed image text
Answer #1

def intValueCheck(strData):

               intData = 0

               while True:

                              try:

                                             intData = int(strData)

                              except ValueError:

                                             print('\t\tThe data entered was not an integer numeric value.. please re-renter...')

                                             strData = input('\t\tRe-enter the data as a integer value: ')

                              else:

                                             break

               return intData

                                            

def processLoop(remainingYears,current_year,startingSalary, salaryIncrease):

               netTotal = 0

               yearsWorked = 1

              

               for i in range(remainingYears):

                              startingSalary = (startingSalary * salaryIncrease) + startingSalary

                              yearsWorked = yearsWorked + 1

                              current_year = current_year + 1

                              netTotal = netTotal + startingSalary

                              print(yearsWorked, "\t\t", current_year, "\t $", startingSalary)

              

               return netTotal

              

def main():

               #Display Program Purpose

               print("The program will show how much money you will make working a job that gives a inputted percentage increase each year")

               #Declaration and Initialization of Variables

               userName = "" #Variable to hold user's name

               currentYear = 0 #Variable to hold current year input

               birthYear = 0 #Variable to hold birth year input

               startingSalary = 0 #Variable to hold starting salary input

               retirementAge = 0 #Variable to hold retirement age input

               remainingYears = 0 #Variable to hold years left to work

               salaryIncrease = 0 #Variable to hold increase in yearly salary

               i = 0 #Variable i

               newSalary = 0 #Variable to hold new salary input

               yearsWorked = 0 #Variable to hold years spent working input

               netTotal = 0 #Variable to hold total money earned

               #Prompt user to input name

               userName = input("Please enter your first name: ")

               #Prompt user to input the current year

               currentYear = intValueCheck(input("Please enter the current year (xxxx): "))

              

               #Prompt user to input birth year

               birthYear = intValueCheck(input("Please enter your birth year (xxxx): "))

               #Prompt user to input starting salary

               startingSalary = intValueCheck(input("Please enter your starting salary(xxxxx): $"))

               #Prompt user to input salary increase

               salaryIncrease = float(input("Please enter the increase you expect (.xx): "))

               #Prompt user to input expected retirement age

               while(retirementAge != 62 and retirementAge != 67 and retirementAge != 70):

                              retirementAge = intValueCheck(input("Please enter your expected retirement age (62, 67, or 70): "))

               #Calculate value of remainingYears variable

               remainingYears = retirementAge - (currentYear - birthYear)

               #Reinitialize yearsWorked variable to 1

               yearsWorked = 1

               #Display calculations for first year of work

               print(userName, "Estimated remaining years to work: ", remainingYears)

               print("Years Worked\tYear\tSalary")

               print(yearsWorked, "\t\t", currentYear, "\t", "$", round(startingSalary))

               #Calculate salary for each year using for loop logic

               netTotal =processLoop(remainingYears,currentYear,startingSalary,salaryIncrease)

               #Display solution of total money earned over lifetime

              

               print("Total net earnings: $", round(netTotal))

              

main()   

Code Screenshot:

1 2 Bdef intValueCheck (strData) intData = 0 while True 4 try intData-int (strData) except ValueError: print(\tltThe data en

27 28 29 30 31 32 def main): &Display Program Purpose print (The program will show how much money you will make working a jo

Output:

D: \python myprograms>python earnings_until_retirement.py The program will show how much money you will make working a job th

34 35 36 37 38 39 40 2051 $80667.0 2052 $85507.0 2053 $90638.0 2054 $96076.0 2055 $101841.0 2056 $107951.0 2057 $114428.0 205

Add a comment
Know the answer?
Add Answer to:
using this code to complete. it python 3.#Display Program Purpose print("The program will show how much...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using python, write code for problem. Please also put screenshot of your code. The following program...

    Using python, write code for problem. Please also put screenshot of your code. The following program will perform properly if the user enters 0 in response to the request for input. However, the program will crash if the user responds with "eight". Rewrite the program using a try/except statement so that it will handle both types of responses. See Fig. 6.1. while True: n = int (input ("Enter a nonzero integer: ")) if n! = 0: reciprocal = 1/n print...

  • Swapping Values in python Summary In this lab, you complete a Python program that swaps values...

    Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....

  • This is for a java program public class Calculation {    public static void main(String[] args)...

    This is for a java program public class Calculation {    public static void main(String[] args) { int num; // the number to calculate the sum of squares double x; // the variable of height double v; // the variable of velocity double t; // the variable of time System.out.println("**************************"); System.out.println(" Task 1: Sum of Squares"); System.out.println("**************************"); //Step 1: Create a Scanner object    //Task 1. Write your code here //Print the prompt and ask the user to enter an...

  • Write a PYTHON program that allows the user to navigate the lines of text in a...

    Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...

  • package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task...

    package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task #1 before adding Task#2 where indicated. */ public class NumericTypesOriginal { public static void main (String [] args) { //TASK #2 Create a Scanner object here //identifier declarations final int NUMBER = 2 ; // number of scores int score1 = 100; // first test score int score2 = 95; // second test score final int BOILING_IN_F = 212; // boiling temperature double fToC;...

  • Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the...

    Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the opposite of what you have done in Assignment 4). Make sure that you create a new Project and Java class file for this assignment. Your file should be named “Main.java”. You can read about octal-to-decimal number conversions on wikepedia Assignment 4 is at the bottom Objective Your program should prompt the user to enter a number of no greater than 8 digits. If the...

  • I need to create a code for this prompt: In this project we will build a...

    I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...

  • in c++ language 1.Re-write the following for loop statement by using a while loop statement: int...

    in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){                 sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() {    int score, highest;             //missing portion of the program             return 0;    } 1(c). Find the missing portion of the following code, so the...

  • C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show...

    C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show super and sub class relationships with an array of super media pointers to sub class objects and dynamic binding. The < operator will be overloaded in the super class so all subclasses can use it. The selection sort method will be in the main .cpp file because it will sort the array created in main. The final .cpp file, the three .h header class...

  • IN C++ Help to fix code Library management program. Error is when i type a letter...

    IN C++ Help to fix code Library management program. Error is when i type a letter into options menu the code breaks. after your edits, the code should still run as normal. CODE: #include<iostream> using namespace std; //structure to store library data class BookDetails{ public: struct library { int code; char title[20]; int status; }; library book_details[100]; }; //structure to store user data class UserDetails:public BookDetails{ public: struct users { int id; char name[20]; int booksNumber; }; users user_details[100]; };...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT