60 412
Assignments Done
Successfully Done
In April 2018

Answer to Question #65448 in Java | JSP | JSF for gazibo

Question #65448
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.
Expert's answer
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 + "%");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions