how to solve this? please help . Cant understand 24th
Attachments:
Ankit02:
I can solve it
Answers
Answered by
21
/** This is the Code for the Required Program.
* Copy it entirely into an IDE, like BlueJ or Eclipse or whatever you use.
* Description and Explanations are given as comments.
* Screenshots of Program Output are attached.
*
* @author Purva
* @since 2018-06-30
*/
import java.util.Scanner; //Importing Scanner for input
public class Brainly //Creating a Class
{
public static void main(String[] args) //Creating main() function
{
Scanner sc = new Scanner(System.in); //Declaring Scanner Object
System.out.println("---KUMAR ELECTRONICS---\n"); //Just Printing Name of Store
System.out.print("Enter Name: "); //Asking User Input for Name
String name = sc.nextLine(); //Scanning User Input for Name
System.out.print("Enter Amount of Purchase: "); //Asking for Amount of Purchase
double amount = sc.nextDouble(); //Scanning User Input for Amount of Purchase
System.out.print("Enter Type of Purchase [L/D]: "); //Asking for Type of Purchase
char type = sc.next().charAt(0); //Scanning User Input for Type of Purchase
if(type=='l' || type == 'd' || type == 'L' || type == 'D') //If Type of Purchase is valid, only then code will be executed
{
System.out.println(); //Printing a blank line
double discount = 0; //Creating a discount variable, initialising it to zero
if(amount<=25000) //Condition of amount<=25,000
{
if (type=='l' || type == 'L') //Condition of Laptop
{
discount = 0*amount; //Discount = 0% = 0
}
else //Condition of Desktop Computer
{
discount = 0.05*amount; //Discount = 5% = 0.05
}
}
else if(amount<=50000) //Condition of 25,000 < amount <= 50,000
{
if (type=='l' || type == 'L') //Condition of Laptop
{
discount = 0.05*amount; //Discount = 5% = 0.05
}
else //Condition of Desktop Computer
{
discount = 0.075*amount; //Discount = 7.5% = 0.075
}
}
else if(amount<=100000) //Condition of 50,000 < amount <= 100,000
{
if (type=='l' || type == 'L') //Condition of Laptop
{
discount = 0.075*amount; //Discount = 7.5% = 0.075
}
else //Condition of Desktop Computer
{
discount = 0.10*amount; //Discount = 10% = 0.10
}
}
else //Condition of amount > 100,000
{
if (type=='l' || type == 'L') //Condition of Laptop
{
discount = 0.10*amount; //Discount = 10% = 0.10
}
else //Condition of Desktop Computer
{
discount = 0.15*amount; //Discount = 15% = 0.15
}
}
double net = amount - discount; //Calculating Net Amount to be paid
System.out.println("Hello "+name); //Printing a greeting
System.out.println("The Amount to be Paid is INR "+net); //Printing Final Net Amount to be paid
}
else //Condition of Invalid Type of Purchase
{
System.out.println("Invalid Type of Purchase"); //Printing Invalid Purchase Type Message
}
}
}
* Copy it entirely into an IDE, like BlueJ or Eclipse or whatever you use.
* Description and Explanations are given as comments.
* Screenshots of Program Output are attached.
*
* @author Purva
* @since 2018-06-30
*/
import java.util.Scanner; //Importing Scanner for input
public class Brainly //Creating a Class
{
public static void main(String[] args) //Creating main() function
{
Scanner sc = new Scanner(System.in); //Declaring Scanner Object
System.out.println("---KUMAR ELECTRONICS---\n"); //Just Printing Name of Store
System.out.print("Enter Name: "); //Asking User Input for Name
String name = sc.nextLine(); //Scanning User Input for Name
System.out.print("Enter Amount of Purchase: "); //Asking for Amount of Purchase
double amount = sc.nextDouble(); //Scanning User Input for Amount of Purchase
System.out.print("Enter Type of Purchase [L/D]: "); //Asking for Type of Purchase
char type = sc.next().charAt(0); //Scanning User Input for Type of Purchase
if(type=='l' || type == 'd' || type == 'L' || type == 'D') //If Type of Purchase is valid, only then code will be executed
{
System.out.println(); //Printing a blank line
double discount = 0; //Creating a discount variable, initialising it to zero
if(amount<=25000) //Condition of amount<=25,000
{
if (type=='l' || type == 'L') //Condition of Laptop
{
discount = 0*amount; //Discount = 0% = 0
}
else //Condition of Desktop Computer
{
discount = 0.05*amount; //Discount = 5% = 0.05
}
}
else if(amount<=50000) //Condition of 25,000 < amount <= 50,000
{
if (type=='l' || type == 'L') //Condition of Laptop
{
discount = 0.05*amount; //Discount = 5% = 0.05
}
else //Condition of Desktop Computer
{
discount = 0.075*amount; //Discount = 7.5% = 0.075
}
}
else if(amount<=100000) //Condition of 50,000 < amount <= 100,000
{
if (type=='l' || type == 'L') //Condition of Laptop
{
discount = 0.075*amount; //Discount = 7.5% = 0.075
}
else //Condition of Desktop Computer
{
discount = 0.10*amount; //Discount = 10% = 0.10
}
}
else //Condition of amount > 100,000
{
if (type=='l' || type == 'L') //Condition of Laptop
{
discount = 0.10*amount; //Discount = 10% = 0.10
}
else //Condition of Desktop Computer
{
discount = 0.15*amount; //Discount = 15% = 0.15
}
}
double net = amount - discount; //Calculating Net Amount to be paid
System.out.println("Hello "+name); //Printing a greeting
System.out.println("The Amount to be Paid is INR "+net); //Printing Final Net Amount to be paid
}
else //Condition of Invalid Type of Purchase
{
System.out.println("Invalid Type of Purchase"); //Printing Invalid Purchase Type Message
}
}
}
Attachments:
Answered by
16
Your Answer :-
import java.util.Scanner;public class ankit {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); System.out.print("Enter name: "); String name = scanner.nextLine(); System.out.print("Enter address: "); String address = scanner.nextLine(); System.out.print("Enter type of purchase: "); String type = scanner.nextLine(); System.out.print("Enter amount of purchase: "); int amount = scanner.nextInt(); double discountRate = 0.0; if (type.equals("L")) {
if (amount <= 25000) {
discountRate = 0; } else if (amount >= 25001 && amount <= 57000) {
discountRate = 5.0; } else if (amount >= 57001 && amount <= 100000) {
discountRate = 7.5; } else if (amount > 100000) {
discountRate = 10.0; } } else if (type.equals("D")) {
if (amount <= 25000) {
discountRate = 5.0; } else if (amount >= 25001 && amount <= 57000) { discountRate = 7.6; } else if (amount >= 57001 && amount <= 100000) { discountRate = 10.0; } else if (amount > 100000) { discountRate = 15.0; } } double discount = (discountRate / 100) * amount; double netAmount = amount - discount; System.out.println("Name: " + name); System.out.println("Address: " + address); System.out.println("Net Amount: " + netAmount);
}}
_____________
_____________
ANKIT
import java.util.Scanner;public class ankit {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); System.out.print("Enter name: "); String name = scanner.nextLine(); System.out.print("Enter address: "); String address = scanner.nextLine(); System.out.print("Enter type of purchase: "); String type = scanner.nextLine(); System.out.print("Enter amount of purchase: "); int amount = scanner.nextInt(); double discountRate = 0.0; if (type.equals("L")) {
if (amount <= 25000) {
discountRate = 0; } else if (amount >= 25001 && amount <= 57000) {
discountRate = 5.0; } else if (amount >= 57001 && amount <= 100000) {
discountRate = 7.5; } else if (amount > 100000) {
discountRate = 10.0; } } else if (type.equals("D")) {
if (amount <= 25000) {
discountRate = 5.0; } else if (amount >= 25001 && amount <= 57000) { discountRate = 7.6; } else if (amount >= 57001 && amount <= 100000) { discountRate = 10.0; } else if (amount > 100000) { discountRate = 15.0; } } double discount = (discountRate / 100) * amount; double netAmount = amount - discount; System.out.println("Name: " + name); System.out.println("Address: " + address); System.out.println("Net Amount: " + netAmount);
}}
_____________
_____________
ANKIT
Attachments:
My Answer is Brainliest .
Means a lot for me .
Similar questions
English,
8 months ago
Math,
8 months ago
Business Studies,
8 months ago
Science,
1 year ago
English,
1 year ago