C++ please
Instructions
Download and modify the Lab5.cpp program.
Currently the program will read the contents of a file and display each line in the file to the screen. It will also display the line number followed by a colon. You will need to change the program so that it only display 24 lines from the file and waits for the user to press the enter key to continue.
Do not use the system(“pause”) statement.
Download Source Lab 5 File:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
ifstream file; // File stream object
string name; // To hold the file name
string inputLine; // To hold a line of input
int lines = 0; // Line counter
int lineNum = 1; // Line number to display
// Get the file name.
cout << "Enter the file name: ";
getline(cin, name);
// Open the file.
file.open(name);
// Test for errors.
if (!file)
{
// There was an error so display an error
// message and end the program.
cout << "Error opening " << name << endl;
}
else
{
// Read the contents of the file and display
// each line with a line number.
while (!file.eof())
{
// Get a line from the file.
getline(file, inputLine, '\n');
// Display the line.
cout << setw(3) << right << lineNum
<< ":" << inputLine << endl;
// Update the line display counter for the
// next line.
lineNum++;
// Update the total line counter.
lines++;
}
// Close the file.
file.close();
}
return 0;
}
In: Computer Science
Java assignment, abstract class, inheritance, and polymorphism.
these are the following following classes:
Animal (abstract)
o Example output: Tom says meow.
Mouse
o Example output: Jerry is chewing on cheese.
Cat
o Example output: Tom is chasing Jerry.
TomAndJerry
Sample run:
Jerry says squeak.
Tom says meow.
Jerry is chewing on cheese.
Tom is chasing Jerry.
In: Computer Science
9.9 LAB: Artwork label (classes/constructors)
Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise.
Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values.
class Artist:
def __init__(self,name, birth_year, death_year):
self.name = 'None'
self.birth_year = 0.0
self.death_year = 0.0
def print_info(self):
if death_year == -1:
print('Artist:', name,'born' ,birth_year)
else:
print('Artist:', name,'(',birth_year,'-',death_year,')')
class Artwork:
def __init__(self,title,year_created,artist):
self.title = 'none'
self.year_created = 0.0
self.artist = Artist(name,birth_year,death_year)
def print_info(self):
print('Title:',end= ' ')
print(title,end= ' ')
print(year_created)
if __name__ == "__main__":
user_artist_name = input()
user_birth_year = int(input())
user_death_year = int(input())
user_title = input()
user_year_created = int(input())
user_artist = Artist(user_artist_name, user_birth_year, user_death_year)
new_artwork = Artwork(user_title, user_year_created,
user_artist)
new_artwork.print_info()
Whats wrong with my code? It keeps saying Title and Artist arn't defined. And it won't print class artist.
In: Computer Science
this code still shows that it still has an syntax error in it can you please fix it. I will put an error message next to the line that is wrong and needs fixed, other than that the other lines seems to be ok.
public static void main()
{
/**
* main method - makes this an executable program.
*/
public static void main("String[]args"); this is the error line
that I get and needs fixed
// create a client with placeholder values
system.out.println("Client with default information");
// create a client object using first constructor
Client client1 = new Client();
// Display information about the client
System.out.println(client1.toString());
System.out.println();
System.out.println("Create a client by providing
information");
// client last name - Jameson
// client first name - Rebecca
// client age - 32
// client height - 65
// client weight - 130
Client client2 = new Client("Jameson", "Rebecca",
32, 65, 130);
// Display information about the client
System.out.println(client2.toString());
// Display the first name
System.out.println("original first name = " +
client2.getFirstName());
// set the first name to the value Rachel
client2.setFirstName("Rachel");
// Retrieve and dislplay the client first name
System.out.println("new first name = " +
client2.getFirstName());
// Display information about the client
System.out.println(client2.toString());
// set their weight to 180
client2.setWeight(180);
// Display information about the client
System.out.println(client2.toString());
}
}
In: Computer Science
Assignment Description
Write a program that will have a user guess whether a person is a musician or a writer. You will create a
group of four names, two musicians and two writers, and show the user a name randomly selected from
the four. The user will then guess whether they think the name belongs to a musician or writer. After a
guess, the program will tell the user whether they are correct, repeat the name, and reveal the correct
answer.
Tasks
1) The program needs to contain the following
a.
A comment header containing your name and a brief description of the program
b. At least 5 comments besides the comment header explaining what your code does
c.
Four string variables, two musicians and two writers
d. A way to randomly display one of the four names to the user
e. Output asking the user whether the name displayed is a musician or a writer
i. If the user guesses correctly, congratulate them before outputting the displayed
name and the correct answer
ii. If the user guesses incorrectly, output the displayed name and the correct
answer
f.
“Press enter to continue” and Console.Read(); at the end of your code
2) Upload the completed .cs file onto the Assignment 3 submission folder. To access the .cs file:
a.
Right click on your program tab
b. Click “Open containing folder”
c.
The file you are working on will be there with a .cs extention, upload the .cs file
In: Computer Science
Part (a) CREATE TWO TABLES IN MICROSOFT ACCESS: (1) A Customer Table which includes the following fields: Customer Name, Customer Address, and Credit Limit. (Note: All customers have a $40,000 credit limit). (2) A Sales Invoice table which includes the following fields: Customer Name, Salesperson, Date of Sale, Invoice Number, Amount of Sale. Part (b): Run the following queries: Query 1: List all sales between 10/20/2014 and 11/20/2014 that were greater than $2,500. Include in your query the customer name, date of sale, invoice number, and amount of sale. List the sales in alphabetical order by customer name. Query 2: List total sales by each salesperson for October and November 2014 in descending order. Include in your query the salesperson name and amount of total sales. Query 3: List the total sales by customer in descending order. Include in your query the customer name, customer address, and amount of total sales per customer. Query 4: List the remaining credit available for each customer. Include in your query the customer name, customer address, credit limit, amount of total sales per customer, and remaining credit available for each customer in descending order of remaining credit available.
In: Computer Science
The following case study (Rinehart?Thompson) at hypothetical St.
John Hospital illustrates numerous
issues that the HIPAA privacy rule presents and which HIPAA?covered
entities must address on a daily
basis. As you conclude Chapter 9 and the HIPAA privacy rule
requirements, use this case study to
identify the issue(s) presented on each date, determining how each
situation should be handled in order
to comply with the HIPAA privacy rule.
From May 26?30, Mary Jones was hospitalized in St. John Hospital,
located in Johnson County, with
depression and a drug overdose (documented by the physician as
possible suicide attempt). She also
had Type I diabetes and a previous above?knee amputation of the
right leg, with prosthesis. During her
hospital stay, she had several sessions with her psychiatrist, Dr.
Bridges.
On July 18, Ms. Jones contacted the HIM Department at St. John
Hospital to request a copy of her
medical records from her May hospital admission. The chart was
copied for her by ReadyChart, the
record?copying service utilized by St. John Hospital.
On August 7, Ms. Jones returned to the HIM Department at St. John
Hospital, extremely upset that her
May records indicated a possible suicide attempt. She wanted Dr.
Bridges to change the incorrect
records to reflect that the overdose was accidental. Dr. Bridges
refused, stating that Ms. Jones didn’t
know what she was talking about.
On September 14, Ms. Jones was readmitted to St. John Hospital with
an infection of the prosthetic site.
She was treated with an antibiotic regimen.
On October 5, St. John Hospital received a call from Mercy
Hospital. Ms. Jones was in the emergency
department there, with a severe infection of her prosthetic site.
The nurse in the Mercy Hospital
emergency department asked for faxed copies of medical records from
Ms. Jones’ September admission
at St. John, as she was being prepared for immediate surgery.
On October 15, Ms. Jones decided to go to another psychiatrist. She
called St. John Hospital HIM
Department and asked that her medical records from her May hospital
admission be mailed to Dr. Lyon,
as she has an appointment scheduled with him this coming January.
Ms. Jones stated that she had also
changed jobs in September, and her new health insurer was Liberty
Life and Health.
On October 30, Ms. Jones requested a copy of her medical records
from her September admission. The
new HIM manager in charge of correspondence, Don Day, stated that
he was aware of a state statute
that prohibited the release of medical records to patients without
prior written approval of their
attending physician. This has not been the practice at St. John
Hospital. Mr. Day was concerned about
the hospital’s longstanding violation of state law. He suggested
that correspondence requests (in which
records would be released directly to patients) be suspended until
the state law could be researched
further.
On November 10, Ms. Jones received a brochure and samples from
Comfort Healthcare, a
pharmaceutical company that manufactures ointment for patients with
prostheses. Ms. Jones called the
St. John Hospital registration desk to complain. Jessica Carter, a
candystriper, took Ms. Jones’ call.
On November 12, Liberty Life and Health submitted a request to Dr.
Lyon’s office for copies of Ms.
Jones’ medical records from her May St. John Hospital admission and
from Dr. Lyon’s office.
On November 17, A case worker from the Johnson County Children’s
Services called the HIM
Department at St. John and requested Ms. Jones’ medical records
from her May hospitalization.
Children’s Services had received a complaint that Ms. Jones had an
“episode” on May 26 and there was
concern that her children were being subjected to ongoing abuse. As
a result, it was initiating an
investigation.
On November 20, the physical therapy department at St. John
Hospital is performing a correlational
study to determine the effects of two different types of treatment
that the physical therapy department
has used with its above?knee amputation patients during the past
two years. Ms. Jones received
treatment from the St. John physical therapy department during her
September admission.
On November 21, Dr. King, an orthopedic surgeon, presented a
seminar to the state association of
orthopedic surgeons on above?knee amputation techniques. He had
performed Ms. Jones’ procedure
one year ago, and he showed slides that compared her condition
before the procedure, immediately
after, six months later, and one year later.
Based on the HIPAA privacy rule issues discussed in Chapter 9,
identify the issue or issues presented on
each date in the above case study.
In: Nursing
Below are the control strategy of hydraulic hybrid vehicle. How can I modify code below to include the torque of motor of hydraulic hybrid vehicle? and How can I improve this
function [SOC,k,T_engine,S_engine,T_brake,T_pump] = strategy(duration,gamma,P,V,Pmin,Pmax,Vmin,Vmax,SOC,Disp,T_wheel,S_wheel,gearratio,S_map,Te_max,T_engine,S_engine,T_pm,k,eff_mech,eff_hyd)
S_flywheel = S_wheel*gearratio;
T_flywheel = T_wheel/gearratio;
T_brake = 0;
if SOC < 0.1
k=1; %Engine on
elseif SOC > 0.7
k=0; %Engine off
end
%T_pump +ve = charging
%T-pump -ve = discharging
if k==1
if T_engine*eff_mech < T_flywheel
%Engine provides full torque when hydraulic is insufficient to
support
if SOC < 0.1
T_engine = T_flywheel/eff_mech;
Tmax = interp1(S_map,Te_max,S_engine);
if T_engine > Tmax
T_engine = Tmax;
end
end
T_pump = T_engine*eff_mech-T_flywheel;
elseif T_engine*eff_mech >= T_flywheel && T_flywheel
>= 0
T_pump = T_engine-T_flywheel/eff_mech;
elseif T_engine*eff_mech >= T_flywheel && T_flywheel
< 0
T_pump = T_engine-T_flywheel;
end
elseif k==0
T_pump = -T_flywheel;
T_engine = 0;
S_engine = 0;
end
%Stop charging when accumulator is full
if SOC >= 1 && T_pump > 0
T_pump = 0;
T_brake = -T_wheel;
end
%Including hydraulic efficiency
if T_pump > 0 %Charging thus real torque is smaller
T_pump = T_pump*eff_hyd;
elseif T_pump < 0 %Discharging thus requires higher real
torque
T_pump = T_pump/eff_hyd;
end
%Torque of pump does not exceed its limit
if T_pump >= T_pm
T_brake = (T_pump-T_pm)*gearratio/eff_hyd;
T_pump = T_pm;
elseif T_pump <= -T_pm
T_pump = -T_pm;
T_brake = nan;
end
%Accumulator will charge to full
if SOC > 0.6
Qmax = (V-Vmin)/duration;
x_max = Qmax/(S_flywheel*Disp);
Tmax = P*Disp*x_max;
if T_pump > Tmax
T_pump = Tmax;
if T_brake == 0
T_brake =
(T_engine*eff_hyd-T_pump)*gearratio/eff_hyd-T_wheel;
elseif T_brake > 0
T_brake =
T_brake+(T_engine*eff_hyd-T_pump)*gearratio/eff_hyd-T_wheel;
end
end
end
x = T_pump/(P*Disp);
Q = S_flywheel*Disp*x*duration;
if Q == 0
SOC = SOC;
else
%V is volume of nitrogen gas; Q is rate of change of fluid
pumped
V = V-Q;
SOC = (0.9*((Vmax/V)^gamma)-1)*Pmin/(Pmax-Pmin);
end
In: Mechanical Engineering
A)A bomb calorimeter, or constant
volume calorimeter, is a device often used to determine the heat of
combustion of fuels and the energy content of foods.
Since the "bomb" itself can absorb energy, a separate experiment is
needed to determine the heat capacity of the calorimeter. This is
known as calibrating the
calorimeter.
In the laboratory a student burns a 0.392-g sample
of bisphenol A
(C15H16O2) in a
bomb calorimeter containing 1140. g of water. The
temperature increases from 25.00 °C to
27.40 °C. The heat capacity of water is 4.184 J
g-1°C-1.
The molar heat of combustion is −7821 kJ per mole
of bisphenol A.
C15H16O2(s) + 18 O2(g) ------>15 CO2(g) + 8 H2O(l) + Energy
Calculate the heat capacity of the calorimeter.
heat capacity of calorimeter =_________
J/°C
B)
|
A bomb calorimeter, or a constant volume calorimeter, is a device often used to determine the heat of combustion of fuels and the energy content of foods. In an experiment, a 0.5574 g sample of benzil (C14H10O2) is burned completely in a bomb calorimeter. The calorimeter is surrounded by 1.379×103 g of water. During the combustion the temperature increases from 26.36 to 28.99 °C. The heat capacity of water is 4.184 J g-1°C-1.The heat capacity of the calorimeter was determined in a previous experiment to be 847.1 J/°C. Assuming that no energy is lost to the surroundings, calculate the molar heat of combustion of benzil based on these data. C14H10O2(s) + (31/2) O2(g) ------->5 H2O(l) + 14 CO2(g) + Energy Molar Heat of Combustion = _________ kJ/mol C) A bomb calorimeter, or a constant volume calorimeter, is a device often used to determine the heat of combustion of fuels and the energy content of foods. In an experiment, a 0.9900 g sample of β-D-fructose (C6H12O6) is burned completely in a bomb calorimeter. The calorimeter is surrounded by 1.292×103 g of water. During the combustion the temperature increases from 21.82 to 24.12 °C. The heat capacity of water is 4.184 J g-1°C-1.The heat capacity of the calorimeter was determined in a previous experiment to be 991.1 J/°C. Assuming that no energy is lost to the surroundings, calculate the molar heat of combustion of β-D-fructose based on these data. C6H12O6(s) + 6O2(g) -------> 6 H2O(l) + 6 CO2(g) + Energy Molar Heat of Combustion = ____________ kJ/mol All three problems are a set for one question on my homework, so please answer all three. Thank you so much! |
In: Chemistry
Experiment 2 – Light Independent Reaction
After the light dependent reaction, the light independent takes place. During this phase, also known as the Calvin Cycle, the energy generated in the light independent phase is used to fixate the carbon atoms from carbon dioxide and glucose is produced.
In this experiment you will use baby spinach leaves to demonstrate the utilization of carbon dioxide during the light independent reaction of photosynthesis. Phenol red is an organic dye that undergoes a color change according to pH . The color of this compound will appear as follows:
Because phenol red can be used to detect changes in pH, it can also be used as an indirect method of detecting changes in the amount of CO2 dissolved in a solution. When CO2 is added to a solution, some of it reacts with water to produce an acid called carbonic acid. In turn, some of the carbonic acid dissociates to increase the [H+] in the solution. Therefore, if the amount of CO2 in a solution is increased, the [H+] increases (pH is lowered) and the solution becomes more acidic. It also follows that if the amount of CO2 in a solution is lowered (e.g., by removal of CO2 from the solution), the [H+] will decrease (pH increases) and the solution becomes more basic. The chemical reactions involved are shown below.
To detect the process of carbon fixation (CO2 reduction), you will use this pH indicator to detect changes in the CO2 level.
Materials
Fresh spinach leaves
2 glass test tubes
2 - 250 ml beakers
Phenol red solution
Permanent marker or wax pencil
Water *
Sunshine or bright light source *
Stopwatch/timer
Metric ruler
Procedure
Add 20 ml of phenol red solution to 2 glass test tubes.
With your straw , blow bubbles over the top of the solution until it turns yellow. The color change occurs when the water in the phenol red solution and the CO2 are combined forming carbonic acid . Make sure that both tubes are the same shade of yellow.
Add a small leaf of baby spinach to tube 2 only
Place the 2 test tubes into sunshine or a bright light at time for 2 hours.
Record the color every ½ hour.
|
Table 2: Change is Color (phenol red) |
|||||
|
0 time |
½ hour |
1 hours |
1 ½ hours |
2 hours |
|
|
Tube 1 |
|||||
|
Tube 2 |
|||||
Questions
What is the independent variable in this experiment?
What is the dependent variable in this experiment?
What happened to the color of the solution over time?
What is the process that is occurring to make the phenol red solution change colors?
What is the function of the following components in the process of photosynthesis (this may differ than how this compounds were used in the experiment)
CO2:
Light:
H2O:
O2:
Chloroplasts:
In: Biology