Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program.cs Your program should have the following methods ( functions ) : DisplayHeader Displays header for pressure calc program. GetMolecularWeights This method gets Molecular Weights
Program.cs
Your program should have the following methods functions:
DisplayHeader
Displays header for pressure calc program.
GetMolecularWeights
This method gets Molecular Weights arrays from file.
Prototype: static void GetMolecularWeightsref string gasNames, ref double molecularWeights, out int count
gasNames is a string array that will be filled by the function with gas names.
"molecularWeights" is a double array that will be filled by this function with molecular weights.
"count" is a double that is passed in as an out parameter and will be loaded with the count of elements in array.
Use a StreamReader to open the file and read its contents. You can use the string split function to split the data on a comma.
DisplayGasNames
Given an array of gas names display gas names in columns.
Prototype: private static void DisplayGasNamesstring gasNames, int countGases
gasNames is an array of strings with gas names.
countGases is the count of names in the array.
This function should display the names of the gases to the console in three columns.
GetMolecularWeightFromName
This function looks up the name of a gas in an array of gas names then returns the molecular weight of that gas in mols.
Prototype: private static double GetMolecularWeightFromNamestring gasName, string gasNames, double molecularWeights, int countGases
gasName is the name of gas to search for as a string.
gasNames is an array of gas names
molecularWeights is an array of molecular weights. This array is parallel to the gasNames array.
"countGases" is the count of elements in gasNames and molecularWeights arrays.
Pressure
Given mass, volume, temperature and molecular weight returns pressure of a gas in pascals.
Prototype: static double Pressuredouble mass, double vol, double temp, double molecularWeight
"mass" is mass in grams.
"vol" is volume in cubic meters.
temp is temperature in celcius.
This method will use the parameters to calculate pressure of the gas. Pressure will call NumberOfMoles to get n for the formula. This method will call CelciusToKelvin to convert degrees celcius into degrees kelvin since the formula requires temperature to be in degrees kelvin.
NumberOfMoles
Given the mass of a gas and the molecular weight of that gas, returns the number of moles of air from mass.
Prototype: static double NumberOfMoles double mass, double molecularWeight
"mass" is mass of the gas in grams.
molecularWeight is the molecular weight of the gas in mols.
CelciusToKelvin
Converts Celsius to kelvin.
Prototype: static double CelciusToKelvindouble celcius
celcius is degrees Celsius.
DisplayPresure
Given pressure in Pascals, this function displays pressure in Pascals and PSI to the consol.
Prototype: private static void DisplayPresuredouble pressure
"pressure" is pressure in Pascals.
This function will call PaToPsi to convert the pressure passed to it in Pascals to PSI. It should display pressure in both Pascals and PSI.
PaToPSI
Converts Pascals to PSI.
Prototype: static double PaToPSIdouble pascals
"pascals" is the pressure in pascals.
The method returns Pressure in PSI as a double.
Main Method
The main method will do the following:
Declare double arrays for gas names and molecular weights. Declare an int to keep track of number of elements in the arrays.
Call DisplayHeader to show the program header.
Call GetMolecularWeights to fill the arrays and get the count of items in the list.
Call DisplayGasNames to display the gas names to the user in three columns.
In a do another loop do the following:
Ask the user the name of the gas.
Use GetMolecularWeightFromName method to get the molecular weight of the gas selected by the user.
If the gas is not found display an error message, and drop out to the do another loop.
Ask the user for the volume of gas in cubic meters, mass of the gas in grams and temperature in celcius.
Use the Pressure method to get the pressure of the gas in Pascals.
Pass the pressure in pascals to the DisplayPressure method to display the pressure in Pascals and PSI.
Ask the user if they want to do another.
Display a good bye message when they are done.
THE IDEAL Gas Equation:
The ideal gas equation is:
We want pressure, so we will use the formula in the following format:
P represents pressure in Pascals metric unit for pressure
Make sure you are using m Pascals, Mols and Kelvin in your calculations! You will need to do
appropriate conversions.
T is temperature in degrees Kelvin. To convert from degrees Celsius to kelvin just add degree.
Therefore:
is volume in meters cubed.
is the number of moles of gas. It can be calculated as:
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