patternModerate
Chemistry titration calculator
Viewed 0 times
calculatortitrationchemistry
Problem
This is a Perl program intended for my chemistry class. Since I am just learning to write in Perl, which is my first language, can you tell me if you think that this is well written? If not, could you tell me what is wrong with it or what could be improved?
## Name:Titration
## Beginning of Program
#Input Variables
system "clear"; # Clear the Screen
print "Milliliters Solute: ";
chomp ($milliliters_solute=<>);
print "Milliliters Solvent: ";
chomp ($milliliters_solvent=<>);
print "Molarity of Solvent: ";
chomp ($molarity_solvent=<>);
print "Moles of Solute: ";
chomp ($moles_solute=<>);
print "Moles of Solvent: ";
chomp ($moles_solvent=<>);
system "clear"; # Clear the Screen
#Calculate Answer
$liters_solute=$milliliters_solute/1000;
$liters_solvent=$milliliters_solvent/1000;
$molarity=($liters_solute/$liters_solvent)*($molarity_solvent/1)*($moles_solvent/$moles_solute);
#Print Answer
system "clear"; # Clear the Screen
print "Molarity is $molarity \n";
## End of ProgramSolution
One suggestion, use
Will force you to be a better perl programmer, by enforcing more rigidity to your scripts, and have the intepreter catch any nasty issues that might be otherwise hard to debug.
use warnings;use strict;Will force you to be a better perl programmer, by enforcing more rigidity to your scripts, and have the intepreter catch any nasty issues that might be otherwise hard to debug.
Context
StackExchange Code Review Q#2638, answer score: 13
Revisions (0)
No revisions yet.