Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using JAVA, Create a program that asks the user to enter customer details and then calculates the predicted account balance, and the number of Advantage

Using JAVA, Create a program that asks the user to enter customer details and then calculates the predicted account balance, and the number of Advantage and Preferred coupons for which this balance qualifies. The customer age is entered in years and is converted by the program to months by multiplying by 12. The customer education level is entered as numerical codes: 1 for High school, 2 for bachelors degree, and 3 for masters degree and higher. The codes are then converted to points by dividing by a factor of 0.21. The customers income is entered as whole dollars. The calculated balance is converted to an integer and this is used to calculate the number of Advantage coupons. After taking the Advantage coupons into consideration, the number of Preferred coupons is calculated. Finally, the remaining dollars that do not count towards any coupons are reported. The output of the program is a printout of the customer information with the converted values of age (in months) and education (in points), the predicted account balance and the number of Advantage and Preferred coupons, and the amount of dollars that do not count towards any coupons.

Balance = 27.7 * age + 288.66 * education + 0.387 * income - 9539 where age is the age of the customer in months education is the attained level of education in points income is customers reported annual income in dollars

Instructions: 1. Create named constants to be used by the rest of the code: o Conversion factor for changing years to months: 12 o Conversion factor for changing education codes to points: 0.21 o Number of dollars to qualify for Advantage coupon: 12000 o Number of dollars to qualify for Preferred coupon: 750 2. Prompt the user to enter three numbers: customer age in years, customer education level as a code (1, 2, 3), and customer income in whole dollars. Age should be of type double, education level and income should be integers. Store the values in variables of appropriate names and types. 3. Convert the age to months and education to points. Use named constants for the conversion factors. Store the new values for age and education in new variables of appropriate names and types. 4. Calculate the account balance given the formula above with a double precision math and store the result in a variable of a type double. 5. Declare a new integer variable to store an integer number for the balance. 6. Convert the double value of the balance to an integer value (by casting to a new integer variable). Store this value in the integer variable you created in the previous step, and use this integer balance for the rest of the code. o HINT: Look at the examples in the expressions slides for examples of type casting. 7. Calculate the number of Advantage coupons for which the balance qualifies. Use a named constant for the number of dollars per Advantage coupon. o HINT: You should store the remainder of the balance so that it can be used in the next step 8. Calculate the number of Preferred coupons for which the remainder of the balance qualifies (after the Advantage coupons are taken into account). Use a named constant for the number of dollars per Preferred coupon. 9. Calculate the remainder of the account balance after both coupon types are taken into consideration and store it in a variable. 10. Print to screen the following information: o the age in years and in months o the education in coded form and in points o the income in dollars o the balance in dollars as a double precision result o the balance in dollars as a whole number o the number of Advantage coupons for which the balance qualifies o the number of Preferred coupons for which the balance qualifies o the remainder of the balance that does not count toward any coupons 11. Make sure that your output matches the sample output below, in wording, spacing, capitalization, and punctuation. o HINT: there is a blank line printed to separate the input from the output and another blank line to separate the customer data from the coup

image text in transcribed

Enter age in years: 20 Enter education level (1,2,3): Enter income in whole dollars: 5000 Age: 20.0 years is equal to 240.0 months Education code: 1 is equal to 4.761904761904762 education points Income: 5000 dollars Balance: 418.57142857142753 dollars Balance (int) : 418 dollars This balance qualities for: 0 Advantage coupons and O Preferred coupons Amount not qualifying: 418 dollars BUILD SUCCESSFUL (total time: 6 seconds)

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

Step: 3

blur-text-image

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 Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

What is the difference between paired and independent samples?

Answered: 1 week ago