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

  • SEARCH
  • Home
  • 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 8538483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:07:45+00:00 2026-06-11T11:07:45+00:00

I am writing this program for visual basic that will determine a bill based

  • 0

I am writing this program for visual basic that will determine a bill based off water usage. My problem is that all values I input come back as zero in the command prompt. Can anyone explain what’s wrong with this code?


Option Explicit On
Option Strict On

Imports System

module eurekawatercompany

  Sub Main ()
    ' Declare variables of problem
    Dim waterusage as double 
    Dim totalcharge as double

    ' Prompts for user to enter their water usage.
    Console.write ("Please enter your current water usage (cubic feet): ")
    waterusage = convert.toint32(console.readline())
      If (waterusage < 1000) then
      totalcharge = 15

      End If

      If (1000 > waterusage) and (waterusage < 2000) then
      totalcharge = 0.0175 * waterusage + 15

      End If

      else if (2000 < waterusage) and (waterusage > 3000) then
      totalcharge = 0.02 * waterusage + 32.5

      End If
      ' 32.5 is the price of exactly 2000cm^(3) of water

      else if (waterusage > 3000) then
      totalcharge = 70

      End If

    Console.out.writeline ("Total charge is: ")
      Console.out.writeline (totalcharge)


  End sub

End Module
  • 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-06-11T11:07:46+00:00Added an answer on June 11, 2026 at 11:07 am

    First up, your statement:

    If (1000 > waterusage) and (waterusage < 2000) then
    

    is equivalent to:

    If (waterusage < 1000) and (waterusage < 2000) then
    

    meaning that it’s testing that waterusage is both less than 1000 and less than 2000 (ie, just that it’s less than 1000). I think you may have meant something along the lines of:

    If (waterusage > 1000) and (waterusage <= 2000) then
    

    You’ll notice I’ve used <= as well since your if statements don’t handle the edge cases at all (2000 is neither less than, nor greater than, 2000 so entering 2000 would cause none of your original if statements to fire).

    You’ll also need to make similar changes to the 0 to 1000 and 2000 to 3000 cases.


    I’m also not entirely certain that the:

    :
    End If
    else if ...
    

    construct is correct (unless VB.NET has changed drastically at the lower levels since the VB6 days (I know that there were a lot of changes but changing such a low-level thing as the workings of if would be unlikely). An end if closes off the entire if statement as far as I’m aware, so the else should be between the if and end if.

    So I’d be looking at something like:

    Option Explicit On
    Option Strict On
    Imports System
    Module EurekaWaterCompany
    
    Sub Main ()
        Dim WaterUsage as double
        Dim TotalCharge as double
    
        Console.Out.Write ("Please enter your current water usage (cubic feet): ")
        WaterUsage = Convert.ToInt32 (Console.In.ReadLine())
    
        If (WaterUsage <= 1000) then
            TotalCharge = 15
        ElseIf (WaterUsage > 1000) and (WaterUsage <= 2000) then
            TotalCharge = 0.0175 * WaterUsage + 15
        ElseIf (Waterusage > 2000) and (WaterUsage <= 3000) then
            TotalCharge = 0.02 * WaterUsage + 32.5
        Else
            TotalCharge = 70
        End If
    
        Console.Out.WriteLine ("Total charge is: ")
        Console.Out.WriteLine (TotalCharge)
    End sub
    
    End Module
    

    That code also has some minor fixes like properly specifying Out and In for the I/O, and using “proper” capitalisation, although it’s not fully tested and may still have some syntax errors. The idea behind the code (basically the if statement) is still sound.


    However, you may want to check your specifications.

    When utilities charge for their resource, they tend to levy higher rates on the excess beyond a certain level, not the entire amount. In other words, I’d expect to see a charge of $15 on the first 1000 cubic feet and then 1.75 cents on each cubic foot beyond that, which would make your statements look more like:

    ElseIf (WaterUsage > 1000) and (WaterUsage <= 2000) then
        TotalCharge = 0.0175 * (WaterUsage - 1000) + 15
    

    That would make sense in this situation since you’d be charged 1.5c/ft3 for the first thousand, 1.75c/ft3 for the second thousand, and 2c/ft3 for the third thousand, with a lower limit of $15 (you get charged for the first thousand no matter how much you actually use) and a fixed charge of $70 for anyone who uses more than three thousand cubic feet (sort of a penalty rate).

    But, that’s supposition on my part, from experience. It may be that your specifications say otherwise, in which case feel free to ignore this section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program for my visual basic class that computes the prices of
I'm writing this program in Visual Basic .NET to organize different fields of data,
I was writing this code for a C program that transforms letters to lower
Ok, so, im having trouble with this program im writing, it all seems to
I am writing a program for class that manages a Hotel. This Report1 function
I'm fairly new to Qt. This is my second 'real' program that I'm writing.
I am writing a small program in Visual C++ 2010. This is code of
I am writing a Visual C# program that executes a continuous loop of operations
I am writing a program that will open an image file, but strange thing
I'm writing a program that includes a secondary form using C++/CLI in Visual Studio

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.