Design/Implementation: Are there noticeable issues/flaws in the design and implementation of the code? How would you remedy such issues?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Reviewing this program address the following points:

  1. Design/Implementation: Are there noticeable issues/flaws in the design and implementation of the code? How would you remedy such issues?
  2. Readability: Is the code well organized and easy to follow? Can you understand what is going on, easily?
  3. Documentation: Is the documentation well-written? does it explain what the code is accomplishing and how? Remember good documentation includes descriptive variable and function names in addition to clear/concise annotation.
  4. Efficiency: Was the code efficient, without sacrificing readability and understanding?

#include <iostream>

using namespace std;

int main() 
{
    double meal, tax, tip, total; //create variables
    double taxPercentage = .0675, tipPercentage = .2; //initiate percentage values
    
    cout << "Enter a meal charge: \n";
    cin >> meal; //enter meal
    
    tax = meal * taxPercentage;
    tip = (meal + tax) * tipPercentage;
    total = meal+tax+tip;
    
    
 cout << "Meal Charge: " << meal << endl; /*output the meal charge*/ 
 cout << "Tax: " << tax << endl; /*output the tax*/
 cout << "Tip: " << tip  << endl; /*output the tip*/
 cout << "Total: " << total  << endl;  /*output the total*/

 return 0;
}

 

#include <iostream>

using namespace std;

int main() 
{
    double mealCharge;      // declaring variables to be used
    double Tax;
    double Tip;   
    double Total;
    
    cout << "Enter a meal charge: ";    // asking user for meal charge input
    cin >> mealCharge;                                      // assigning user input to mealCharge
    
    Tax = mealCharge * .0675;                           // math, deriving tip tax and total from mealCharge
    Tip = (mealCharge + Tax) * .2;
    Total = mealCharge + Tip + Tax;
    
 cout << "Meal Charge: " << mealCharge << endl;      // Outputing answers
 cout << "Tax: " << Tax << endl;
 cout << "Tip: " << Tip << endl;
 cout << "Total: " << Total << endl;

 return 0;       // program end
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education