Answered step by step
Verified Expert Solution
Link Copied!

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 GetMolecularWeights(ref 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 3 columns.
Prototype: private static void DisplayGasNames(string[] 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 GetMolecularWeightFromName(string 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 Pressure(double 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 CelciusToKelvin(double 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 DisplayPresure(double 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 PaToPSI(double 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions