-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindCostApp.java
More file actions
39 lines (31 loc) · 1.29 KB
/
FindCostApp.java
File metadata and controls
39 lines (31 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//Lab Task 6
//Tadisa Jakarasi
import java.util.*;
public class FindCostApp
{
public static void main(String[ ] args )
{
Scanner kbd= new Scanner(System.in);
double price, tax; // declaring variables
displayTitle(); // calling method that displays title
System.out.print("Enter initial price: ");// obtaining price input
price = kbd.nextDouble();
System.out.print("Enter tax rate: "); // obtaining tax input
tax = kbd.nextDouble();
price = calculateFinalPrice(price, tax ); // variable receiving the return value from calculateFinalPrice method
displayPrice(price); //calling the method which displays the final cost
System.out.println("END OF PROGRAM "); // indicating program termination
}
static void displayTitle() //method to display the title of program
{
System.out.println("*** Product Price Check ***");
}
static void displayPrice(double priceIn) //method to display final cost of product
{
System.out.println("Cost after tax = " + priceIn);
}
static double calculateFinalPrice(double priceIn , double taxIn)
{
return priceIn * (1 + taxIn/100); // returns value back to main method after calculation
}
}