1. The following steps calculate the percentage profit from the sale of a stock. Convert the statements below to java code.
(a) Declare all variables as type Double.
(b) Ask user to input purchasePrice.
(c) Ask user to input sellingPrice.
(d) Assign, to the variable percentProfit, 100 times the value of the difference between sellingPrice and purchasePrice divided by purchasePrice.
Display the value of the variable percentProfit.
import java.util.Scanner;
public class SaleOfStock {
static double purchasePrice;
static double sellingPrice;
static double percentProfit;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Please input purchasePrice: ");
purchasePrice = scanner.nextDouble();
System.out.println("Please input sellingPrice: ");
sellingPrice = scanner.nextDouble();
percentProfit = 100 * (sellingPrice - purchasePrice);
System.out.println("percentProfit is " + percentProfit + "%");
}
}