Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.

Have an account? Sign In

Captcha Click on image to update the captcha.

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Tech Answered Logo Tech Answered Logo
Sign InSign Up

Tech Answered

Tech Answered Navigation

  • Home
  • Tutorials
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us
Home / Questions /Q 4185
Next
In Process
sita
sita

sita

  • India
  • 105 Questions
  • 59 Answers
  • 1 Best Answer
  • 74 Points
View Profile
  • 0
sita
Asked: December 15, 20222022-12-15T10:33:28+05:30 2022-12-15T10:33:28+05:30In: Java

write a program to calculate the electricity bill in java

  • 0

I got a assignment to write a java program to calculate the electricity bill. Can anyone help me regarding the example program to calculate the electricity bill in java.

example program to calculate the electricity bill in javajava programprogram to calculate the electricity bill in javawrite a programwrite a program to calculate the electricity bill in javawrite a program to calculate the electricity bill in java 2023
  • 1
  • 933
  • 0
  • 0
Answer
Share
  • Facebook

    Related Questions

    • Example Java program using method parameters

    1 Answer

    1. Ranesh
      2022-12-15T10:42:22+05:30Added an answer on December 15, 2022 at 10:42 am

      Here is the sample example program in Java that calculate the electricity bill with given unit rate.

      import java.util.Scanner;

      public class ElectricityBill {
      public static void main(String[] args) {
      Scanner input = new Scanner(System.in);

      // Prompting the user to enter no of units consumed.

      System.out.print(“Enter the no of units consumed: “);

      double units = input.nextDouble();

      // Compute the cost of the electricity bill
      double cost = 0.0;
      if (units <= 100)
      cost = units * 0.5;
      else if (units <= 300)
      cost = 100 * 0.5 + (units – 100) * 0.75;
      else if (units <= 400)
      cost = 100 * 0.5 + 200 * 0.75 + (units – 300) * 1.2;
      else
      cost = 100 * 0.5 + 200 * 0.75 + 100 * 1.2 + (units – 400) * 1.5;

      System.out.println(“The total electricity bill is $” + cost);
      }
      }

      Examples our program that uses method parameters.

      1. The program starts with importing the Scanner class from the java.util package, which is used to read input from the user.
      2. 2. Coming to the logic we need to check the number of unit whether it is less than 100, if so the unit calculation rate will be different.

      • 1
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    More Questions

    • dynamicapps5

      how to solve error illegal start of expression in java

    • Himasree

      How to insert data in java through database?

    • Swathi

      How to run java code in eclipse

    • Swathi

      What is null pointer exception in java?

    • kiran kumar85

      javascript validation client side and submitting to database using webspring

    • Rashika

      When to use volatile variable in Java?

    • Aniya

      how to fix java error in tlauncher authentication

    • Rashika

      How to resolve the issue java.lang.OutOfMemoryError: Java heap space?

    Stats

    • Questions 1,992
    • Answers 2,102
    • Posts 12
    • Best Answers 73

    Related Questions

    • dynamicapps5

      Example Java program using method parameters

    Explore

    • Home
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help

    Footer

    Recent Comments

    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • AaronBlackburn on why can’t i find my message requests on instagram
    • shree on How to use philips citrus press juicer 25 watts Demo
    Ask A Question

    Archives

    Tags

    laptop buying guide (1) limit google news notifications (1) printer buying guide (1) stop google news notifications (1) turn off google news notifications (1)

    Social media

    © 2023 @ Techanswered.com.
    Terms, Privacy policy & Sitemap.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.