Write a program in java to input number of water units consumed.Get the details like consumer name, consumer number, consumer type and the no. of units consumed. If the consumer is “Domestic” compute the total bill amount according to following slab.Below 150 Rs 250151 to 175 Re 1.00 per unit176 to 300 Rs 1.75 per unitAbove 300 Rs 2.25 per unitIf the consumer type is : “Industry” use the following rulesBelow150 Rs 200/=151 to 175 Re 0.75 per unitNext 176 to 300 Rs 1per unitAbove 300 Rs 2 per unit
Question
Write a program in java to input number of water units consumed.Get the details like consumer name, consumer number, consumer type and the no. of units consumed. If the consumer is “Domestic” compute the total bill amount according to following slab.Below 150 Rs 250151 to 175 Re 1.00 per unit176 to 300 Rs 1.75 per unitAbove 300 Rs 2.25 per unitIf the consumer type is : “Industry” use the following rulesBelow150 Rs 200/=151 to 175 Re 0.75 per unitNext 176 to 300 Rs 1per unitAbove 300 Rs 2 per unit
Solution 1
Here is a simple Java program that implements the given problem:
import java.util.Scanner;
public class WaterBill {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter consumer name: ");
String consumerName = scanner.nextLine();
System.out.println("Enter consumer number: ");
String consumerNumber = scanner.nextLine();
System.out.println("Enter consumer type (Domestic/Industry): ");
String consumerType = scanner.nextLine();
System.out.println("Enter number of water units consumed: ");
int units = scanner.nextInt();
double billAmount = 0;
if (consumerType.equalsIgnoreCase("Domestic")) {
if (units <= 150) {
billAmount = 250;
} else if (units <= 175) {
billAmount = units * 1.00;
} else if (units <= 300) {
billAmount = units * 1.75;
} else {
billAmount = units * 2.25;
}
} else if (consumerType.equalsIgnoreCase("Industry")) {
if (units <= 150) {
billAmount = 200;
} else if (units <= 175) {
billAmount = units * 0.75;
} else if (units <= 300) {
billAmount = units * 1.00;
} else {
billAmount = units * 2.00;
}
}
System.out.println("Consumer Name: " + consumerName);
System.out.println("Consumer Number: " + consumerNumber);
System.out.println("Consumer Type: " + consumerType);
System.out.println("Units Consumed: " + units);
System.out.println("Total Bill Amount: " + billAmount);
}
}
This program first takes the consumer details and the number of units consumed as input. It then calculates the bill amount based on the consumer type and the number of units consumed. Finally, it prints out the consumer details and the total bill amount.
Solution 2
Here is a simple Java program that implements the given problem:
import java.util.Scanner;
public class WaterBill {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter consumer name: ");
String consumerName = scanner.nextLine();
System.out.println("Enter consumer number: ");
String consumerNumber = scanner.nextLine();
System.out.println("Enter consumer type (Domestic/Industry): ");
String consumerType = scanner.nextLine();
System.out.println("Enter number of water units consumed: ");
int units = scanner.nextInt();
double billAmount = 0;
if (consumerType.equalsIgnoreCase("Domestic")) {
if (units <= 150) {
billAmount = 250;
} else if (units <= 175) {
billAmount = units * 1.00;
} else if (units <= 300) {
billAmount = units * 1.75;
} else {
billAmount = units * 2.25;
}
} else if (consumerType.equalsIgnoreCase("Industry")) {
if (units <= 150) {
billAmount = 200;
} else if (units <= 175) {
billAmount = units * 0.75;
} else if (units <= 300) {
billAmount = units * 1.00;
} else {
billAmount = units * 2.00;
}
}
System.out.println("Consumer Name: " + consumerName);
System.out.println("Consumer Number: " + consumerNumber);
System.out.println("Consumer Type: " + consumerType);
System.out.println("Units Consumed: " + units);
System.out.println("Total Bill Amount: " + billAmount);
}
}
This program first takes the consumer details and the number of units consumed as input. It then calculates the bill amount based on the consumer type and the number of units consumed. Finally, it prints out the consumer details and the total bill amount.
Solution 3
Here is a simple Java program that implements the given problem:
import java.util.Scanner;
public class WaterBill {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter consumer name: ");
String consumerName = scanner.nextLine();
System.out.println("Enter consumer number: ");
String consumerNumber = scanner.nextLine();
System.out.println("Enter consumer type (Domestic/Industry): ");
String consumerType = scanner.nextLine();
System.out.println("Enter number of water units consumed: ");
int units = scanner.nextInt();
double billAmount = 0;
if (consumerType.equalsIgnoreCase("Domestic")) {
if (units <= 150) {
billAmount = 250;
} else if (units <= 175) {
billAmount = units * 1.00;
} else if (units <= 300) {
billAmount = units * 1.75;
} else {
billAmount = units * 2.25;
}
} else if (consumerType.equalsIgnoreCase("Industry")) {
if (units <= 150) {
billAmount = 200;
} else if (units <= 175) {
billAmount = units * 0.75;
} else if (units <= 300) {
billAmount = units * 1.00;
} else {
billAmount = units * 2.00;
}
}
System.out.println("Consumer Name: " + consumerName);
System.out.println("Consumer Number: " + consumerNumber);
System.out.println("Consumer Type: " + consumerType);
System.out.println("Units Consumed: " + units);
System.out.println("Total Bill Amount: " + billAmount);
}
}
This program first takes the consumer details
Solution 4
Here is a simple Java program that implements the given problem:
import java.util.Scanner;
public class WaterBill {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter consumer name: ");
String consumerName = scanner.nextLine();
System.out.println("Enter consumer number: ");
String consumerNumber = scanner.nextLine();
System.out.println("Enter consumer type (Domestic/Industry): ");
String consumerType = scanner.nextLine();
System.out.println("Enter number of water units consumed: ");
int units = scanner.nextInt();
double billAmount = 0;
if (consumerType.equalsIgnoreCase("Domestic")) {
if (units <= 150) {
billAmount = 250;
} else if (units <= 175) {
billAmount = units * 1.00;
} else if (units <= 300) {
billAmount = units * 1.75;
} else {
billAmount = units * 2.25;
}
} else if (consumerType.equalsIgnoreCase("Industry")) {
if (units <= 150) {
billAmount = 200;
} else if (units <= 175) {
billAmount = units * 0.75;
} else if (units <= 300) {
billAmount = units * 1.00;
} else {
billAmount = units * 2.00;
}
}
System.out.println("Consumer Name: " + consumerName);
System.out.println("Consumer Number: " + consumerNumber);
System.out.println("Consumer Type: " + consumerType);
System.out.println("Units Consumed: " + units);
System.out.println("Total Bill Amount: " + billAmount);
}
}
This program first takes the consumer details and the number of units consumed as input. It then calculates the bill amount based on the consumer type and the number of units consumed. Finally, it prints out the consumer details and the total bill amount.
Solution 5
Here is a simple Java program that implements the given problem:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter consumer name:");
String consumerName = scanner.nextLine();
System.out.println("Enter consumer number:");
String consumerNumber = scanner.nextLine();
System.out.println("Enter consumer type (Domestic/Industry):");
String consumerType = scanner.nextLine();
System.out.println("Enter number of units consumed:");
int unitsConsumed = scanner.nextInt();
double billAmount = 0;
if (consumerType.equalsIgnoreCase("Domestic")) {
if (unitsConsumed <= 150) {
billAmount = 250;
} else if (unitsConsumed <= 175) {
billAmount = unitsConsumed * 1.00;
} else if (unitsConsumed <= 300) {
billAmount = unitsConsumed * 1.75;
} else {
billAmount = unitsConsumed * 2.25;
}
} else if (consumerType.equalsIgnoreCase("Industry")) {
if (unitsConsumed <= 150) {
billAmount = 200;
} else if (unitsConsumed <= 175) {
billAmount = unitsConsumed * 0.75;
} else if (unitsConsumed <= 300) {
billAmount = unitsConsumed * 1.00;
} else {
billAmount = unitsConsumed * 2.00;
}
}
System.out.println("Consumer Name: " + consumerName);
System.out.println("Consumer Number: " + consumerNumber);
System.out.println("Consumer Type: " + consumerType);
System.out.println("Units Consumed: " + unitsConsumed);
System.out.println("Total Bill Amount: " + billAmount);
}
}
This program first takes the consumer name, number, type, and units consumed as input. It then calculates the bill amount based on the consumer type and units consumed. Finally, it prints out the consumer details and the total bill amount.
Similar Questions
To develop a Java application to generate Electricity bill. Create a class with the following members: Consumer no., consumer name, previous month reading, current month reading, type of EB connection (i.e domestic or commercial). Compute the bill amount using the following tariff. If the type of the EB connection is domestic, calculate the amount to be paid as follows:First 100 units - Rs. 1 per unit101-200 units - Rs. 2.50 per unit201 -500 units - Rs. 4 per unit> 501 units - Rs. 6 per unitIf the type of the EB connection is commercial, calculate the amount to be paid as follows:First 100 units - Rs. 2 per unit101-200 units - Rs. 4.50 per unit201 -500 units - Rs. 6 per unit> 501 units - Rs. 7 per unitSample:InputEnter consumer number 1001Enter Type of connection (D for Domestic or C for Commercial) DEnter consumer name SachinEnter previous month reading 3000Enter current month reading 4000OutputConsumer number = 1001Consumer name = Sachintype of connection = DOMESTICCurrent Month Reading = 4000.0Previous Month Reading = 3000.0Total units = 1000.0Total bill = RS 6000.0
Write a program to input the electricity unit consumed and calculate the total electricity bill according to the given conditions: For the first 50 units Rs. 3.50/unit For the next 100 units Rs. 4.50/unit For the next 100 units Rs. 5.20/unit For units above 250 Rs. 6.75/unit An additional surcharge of 20% is added to the bill.Input format :The input consists of the units consumed.Output format :The output prints the final bill amount.Round off the output to two decimal places.Refer to the sample output for formatting specifications.Sample test cases :Input 1 :50Output 1 :210.00Input 2 :150Output 2 :750.00Input 3 :250Output 3 :1374.00Input 4 :300Output 4 :1779.00
Given the number of units consumed by a domestic user in Tamil Nadu, write a program to calculate the electricity bill. The Tamil Nadu electricity bill tariff for domestic user is given belowTamilNadu Electricity BillConsumption upto 500 unitUnits from To Units Unit Cost / KWH 1 100 0 101 200 2.25 201 400 4.50 401 500 6.00Consumption above 500 units 1 100 0 101 400 4.50 401 500 6 501 600 8 601 800 9 801 1000 10Above 1000 units 11 Input Format:Give the number of units consumed:Output Format:Tariff: Sample Input: 400Sample Output:
Write a C Program to input electricity unit charges and calculate the total bill according to the following conditions:For the first 50 units Rs. 0.50/unitFor the next 100 units Rs. 0.75/unitFor the next 100 units Rs. 1.20/unitFor units above 250 Rs. 1.50/unitAn additional surcharge of 20% is added to the bill.Input: User input of no of unit usedOutput: The total bill for the consumed units.
Develop a Java program to help a user manage their daily water intake.Allow the user to input the amount of water consumed (in liters) for morning,afternoon, and evening. Use control statements to calculate the total waterconsumed throughout the day. Implement operators to perform arithmeticcalculations to determine the total water intake. Display the total water intaketo the user and provide feedback on whether they have met or exceeded therecommended daily water intake (e.g., 2.5 liters). Utilize appropriate datatypes, operators, and control statements to help users track and manage theirdaily water intake effectively.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.