patterncppMinor
Dental office program
Viewed 0 times
officeprogramdental
Problem
Here is the code I wrote for my mother's dental office. It fulfills these tasks:
My issue is with cleaning the code to increase readability, because I think there is a better way to write it. I also need help outputting the answers to a .txt file for later reference, but I'm not sure if that will screw up the code.
I am newbie, so tips are very much appreciated. I have a lot of bad habits when it comes to programming.
- determines whether a tooth is anterior or posterior
- determines if the patient needs a filling
- sets up a later appointment
My issue is with cleaning the code to increase readability, because I think there is a better way to write it. I also need help outputting the answers to a .txt file for later reference, but I'm not sure if that will screw up the code.
I am newbie, so tips are very much appreciated. I have a lot of bad habits when it comes to programming.
// fillings program
#include
using namespace std;
int main()
{
bool post, // posterior: ?
ante; // anterior: ?
int fillings; // fillings: Y/N
int tooth_number; // tooth_number: 1-32
int surface_num; // surface_num should be 1-5
int amal_or_comp; // amalgum or composite filling
int cav_deep; // input for if cavity is deep
cout > cav_deep;
if (cav_deep==1)
cout > fillings;
if (fillings==2)
{
cout > tooth_number;
cout =1&&tooth_number> amal_or_comp;
if(amal_or_comp==1)
cout > surface_num;
cout =12&&tooth_number> amal_or_comp;
if(amal_or_comp==1)
cout > surface_num;
cout =17&&tooth_number> amal_or_comp;
if(amal_or_comp==1)
cout > surface_num;
cout =28&&tooth_number> amal_or_comp;
if(amal_or_comp==1)
cout > surface_num;
cout =6&&tooth_number> surface_num;
cout =22&&tooth_number> surface_num;
cout << "Surface # entered: " << surface_num;
}
}
}
}Solution
A couple of style Issues jump out to me.
-
mixed use of
-
I'm not a fan of using a paragraph length name for variables but you have define the variable names and then explained the abbreviation. Just name them a little more explicit and then you can read the code easier?
-
mixed use of
{ braces. I think it is a matter of preference but I find that not using them for the if is confusing when you use them for the else if.if (cav_deep==1)
{
cout > fillings;
if (fillings==2)
{
cout << "Proceed to 'crowns'" << endl;
}
///...-
I'm not a fan of using a paragraph length name for variables but you have define the variable names and then explained the abbreviation. Just name them a little more explicit and then you can read the code easier?
bool posterior,
anterior;
int fillings; // fillings: Y/N
int tooth_number; // tooth_number: 1-32
int surface_num; // surface_num should be 1-5
int amalgum_or_composite;// amalgum or composite filling
int is_cavity_deep;Code Snippets
if (cav_deep==1)
{
cout << "Temporary filling needed. Patient needs to come back for permanent fill at later date." << endl;
}
else if (cav_deep==2)
{
cout << "Fillings Needed?: 1.Yes 2.No" << endl;
cin >> fillings;
if (fillings==2)
{
cout << "Proceed to 'crowns'" << endl;
}
///...bool posterior,
anterior;
int fillings; // fillings: Y/N
int tooth_number; // tooth_number: 1-32
int surface_num; // surface_num should be 1-5
int amalgum_or_composite;// amalgum or composite filling
int is_cavity_deep;Context
StackExchange Code Review Q#32656, answer score: 6
Revisions (0)
No revisions yet.