Question
Just need to verify that this code is correct and has no errors for my assignment. ASSIGNMENT Your program should declare variables using the appropriate
Just need to verify that this code is correct and has no errors for my assignment.
ASSIGNMENT
- Your program should declare variables using the appropriate data types to store the following string values.
Name: John Smith
Address: 101 N. Main Street
City: AnyTown
State: TX
Units Taken: 19
-
For the price per unit, declare a constant numeric variable to contain the decimal value 100.50.
-
For the twenty unit-hour discount, declare a constant numeric variable to contain the whole number 150.
-
Convert the string value for Units Taken to an integer data type andplace the converted numeric value into a separate numeric variable. Hint: Use the same name but add the prefix int such as intUnitsTaken.
-
Using the increment operator, increment the variable above by 1 so that the value 19 will now be 20.
-
Multiply the constant variable for price per unit by the units taken and place the answer in a variable named tuition.
-
Subtract the constant discount value from tuition and store the answer in a variable named afterDiscount.
-
Divide the discounted tuition by 12 and store the answer in a variable named monthlyPayment.
-
Finally, your program will display the following data using the respective variables for each item:
Name
Address
City
State
Zip Code
Number of units taken (numeric value that was incremented)
Tuition before discount
Tuition after discount
Monthly Payment
Include labels for each item as shown in expected output. Format the tuition values and monthly payment as currency.
EXPECTED OUTPUT
Name: John Smith
Address: 101 N. Main Street
City: Anytown
State: TX
Zip Code: 11111
The number of units taken is: 20
The tuition before discount is $2,010.00
The tuition after twenty-unit discount is $1,860.00
Your monthly payment is $155.00
The source code file is the file in your project that contains the code you wrote. Below are listed the file extensions for the source code file for each language:
.cs file for C#
.java file for Java
.php and.js files for web development
Need source code file saved as IT213M1_JACKSON_LANGUAGE
CODE:
package com.test;
import java.util.Scanner; /* * This is IT213M1_JACKSON_LANGUAGE class * */ public class IT213M1_JACKSON_LANGUAGE { /* * PRICE_PER_UNIT is a double constant. * TWENTY_UNIT_DISCOUNT is an int constant. * */ public static double PRICE_PER_UNIT = 100.50; public static int TWENTY_UNIT_DISCOUNT = 150;
public static void main(String[] args) { /* * sc is a Scanner class Object. * It will read data from keyboard. * */ Scanner sc = new Scanner(System.in); /* * We are reading the required inputs from the keyboard. * */ System.out.println("Enter Name"); String name = sc.nextLine(); System.out.println("Enter address"); String address = sc.nextLine(); System.out.println("Enter city"); String city = sc.next(); System.out.println("Enter state"); String state = sc.next(); System.out.println("Enter zipcode"); int zipcode = sc.nextInt(); System.out.println("Enter number of units taken"); int numUnits = sc.nextInt(); System.out.println("Name:"+name); System.out.println("Address:"+address); System.out.println("City:"+city); System.out.println("State:"+state); System.out.println("Zipcode:"+zipcode); System.out.println("The number of units taken is: "+numUnits); System.out.println("The tuition before discount is: $"+numUnits*PRICE_PER_UNIT); /* * If number if units are more than or equal to 20 then we are giving $150 * discount. * */ if(numUnits>=20){ System.out.println("The tuition after twenty-unit discount is : $"+(numUnits*PRICE_PER_UNIT-TWENTY_UNIT_DISCOUNT)); System.out.println("Your monthly payment is : $"+(numUnits*PRICE_PER_UNIT-TWENTY_UNIT_DISCOUNT)/12); } else{ System.out.println("More than 20 units will have discount"); System.out.println("Your monthly payment is : $"+(numUnits*PRICE_PER_UNIT)/12); }
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started