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

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

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

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

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

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4086240
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:41:53+00:00 2026-05-20T18:41:53+00:00

Ok I have got this far and if you run it, it will do

  • 0

Ok I have got this far and if you run it, it will do what you ask. Now when I type in 99999 or -99999 it will not end. Can someone tell me what I am doing wrong. I am suppose to loop until a sentinel value of -99999 is enter for previous meter reading.

 Sub Main()
    ' program to compute a consumer’s electric bill. It will calculate the bill for one or more customers 
    ' by looping until a sentinel value of -99999 is entered for the previous meter reading.
    Dim previousReading As Integer = 0
    Dim currentReading As Integer = 0
    Do While (previousReading <> -99999)
        Dim salesTax As Double
        ' prompt user to input value for previous reading then convert to integer
        Console.WriteLine("Enter the value of previous meter reading")
        previousReading = Convert.ToInt32(Console.ReadLine())
        ' prompt user to input value for current reading then convert to integer
        Console.WriteLine("Enter the value of current meter reading")
        currentReading = Convert.ToInt32(Console.ReadLine())
        Dim kwhConsumed As Integer
        Dim electricCharge, totalBill As Double
        ' calculate KWH consumed
        kwhConsumed = currentReading - previousReading
        ' Use select case to determine electricCharge
        Select Case kwhConsumed
            Case Is < 500
                electricCharge = kwhConsumed * 0.05
            Case 500 To 1000
                electricCharge = 25 + ((kwhConsumed - 500) * 0.055)
            Case Is > 1000
                electricCharge = 52.5 + ((kwhConsumed - 1000) * 0.06)
        End Select
        ' calculate sales tax
        salesTax = electricCharge * 0.085
        ' calculate total charges
        totalBill = electricCharge + salesTax
        ' Output values for kwhConsumed, electricCharge, salesTax, and totalBill
        Console.WriteLine("KWH consumed = " & kwhConsumed & " KWH")
        Console.WriteLine("Electric charge = $" & Math.Round(electricCharge, 2))
        Console.WriteLine("Sales tax = $" & Math.Round(salesTax, 2))
        Console.WriteLine("Total bill = $" & Math.Round(totalBill, 2))
    Loop
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:41:54+00:00Added an answer on May 20, 2026 at 6:41 pm

    You can try using string comparison instead for previousReading <> -99999. You also need to use absolute value to consider both -99999 and 99999. Do something like this

    Do While (previousReading <> 99999) 
    
        //code
      previousReading = Math.Abs(Convert.ToInt32(Console.ReadLine()))
        //code
    
    Loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got this error when using Enterprise Library 3.1 May 2007 version. We
The responses I've got to this question have solved the problem I had in
We have got a custom MembershipProvider in ASP.NET . Now there are 2 possible
We have got loads of options for php + MySQL + Apache combo... Which
I have got a python script which is creating an ODBC connection. The ODBC
I have got a C function in a static library, let's call it A,
I have got the following problem since the server has safe mode turned on,
I have got some code to load an assembly and get all types, which
I have got the following code from here to read an Excel file using
I have got a table in MS Access 2007 with 4 fields. Labour Cost

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.