Question
I am having trouble with getting the program to run and making sure the bugs are clear. I am not getting errors when building the
I am having trouble with getting the program to run and making sure the bugs are clear. I am not getting errors when building the solution or starting the program, but nothing is showing when the program is ran. I am using Visual Studios 2015 and writing in C++. Here is the assignment:
Overview: Debugging is the process of finding and fixing errors (bugs/defects) in your code. It is an essential skill for any programming. Bugs can take many forms: typos, incorrect syntax, missing or improperly used elements (quotations, parentheses,spaces, etc.), as well as larger issues that result from coded items interacting in an unanticipated manner. Regardless of the skill of the programmer, bugs are a part of coding and learning to locate them in your code takes patience and practice.
Prompt: This assignment presents you with broken code that you will need to debug. Analyze the existing source code to identify and correct all bugs. Include a brief written summary of the process you used, the issues you found, and how you corrected them.
The following critical elements should be addressed in your project submission:
Locate and fix the multiple syntax errors.
Ensure that loops/flow control statements function properly.
Edit the code to account for case-sensitivity of variables .
Verify that the program output matches the problem statement requirements, fixing defects as necessary.
Include a brief summary of your debugging process and the errors you corrected.
Submission Guidelines: Your submission is the completed source code file containing functioning code and should start with a header comment containing a title (name, course, date, project number) and your brief process summary.
Here is my code so far:
// Squash_The_Bugs.cpp : This code contains five errors before it will work as desired. Find those errors, // document a description of the errors and their fix, and fix them. Try using the debugger to // step through the program to find the bugs. As you step through, take notice of the information // you can see.
// This program gets an input of number of gallons of water used from the user. // It will then calculate a customer's water bill using the following rules: // A mandatory environmental fee of $15, plus // $2.35 per 1000 gallons for the first 6000, // $3.75 per 1000 gallons for over 6000 to 20000, // $6.00 per 1000 gallons for over 20000. // The bill is then displayed to the user.
#include
int main() { double gallons, charge = 0, total; const int fee = 15; float costUpTo6K = 2.35f, costUpTo20K = 3.75f, costOver20K = 6.00f;
cout << "Enter the total number of gallons used, divided by 1000: "; cin >> gallons;
if (gallons > 20){ charge = (gallons - 20) * costOver20K; charge = charge + (14 * costUpTo20K); charge = charge + (6 * costUpTo6K); } else if (gallons > 6 && gallons <= 20){ charge = (gallons - 6) * costUpTo20K; charge = charge + (6 * costUpTo6K); } else { charge = gallons * costUpTo6K; }
total = charge + fee; cout << "You have used " << gallons << " thousand gallons of water." << endl; cout << "Your total water bill is $" << setprecision(2) << fixed << fee;
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started