Computer Science, asked by DarkAgent131, 9 months ago

I will give u 5 stars + Brainliest+Thanks if u will answer my question Be loyal and respectful, it represents your image. Thank you Explain the below program step by step and line by line import java.util.Scanner; public class KboatShopkeeper { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.print("Enter the selling price: "); double sp = in.nextDouble(); double cp1 = (sp / (1 + (20 / 100.0))); double cp2 = (sp / (1 - (20 / 100.0))); double totalCP = cp1 + cp2; System.out.println("Total Cost Price = " + totalCP); } }

Answers

Answered by Tonks
1

Answer:

The explanation is in italics

import java.util.Scanner;

You imported Scanner class

public class KboatShopkeeper {

You defined the class here

public static  void main(String args[]) {

Method commences

Scanner in = new Scanner(System.in);

Scanner object created

System.out.print("Enter the selling price: ");

double sp = in.nextDouble();

You initialized the selling price

double cp1 = (sp / (1 + (20 / 100.0))); Underlined is profit

Cost price with 20% profit

double cp2 = (sp / (1 - (20 / 100.0))); Underlined is loss

Cost price with 20% loss

double totalCP = cp1 + cp2;

The total cost price which you have to find

System.out.println("Total Cost Price = " + totalCP); } }

And u print the answer here

Hope that helps

Similar questions