Write a java code to ask the user for a string, and assuming the user enters a string containing character "a", your java program must convert all "a" to "b" in the string so for example if user types : "AMAZON" , your program must convert it to "BMBZON"
the driver program must ask :
enter a string containing "a" or "A"
--------- (user enters string)
then it should say;
HERE IS YOUR NEW STRING
---------- (string with all a's converted to b.)
important : all a's should be b and even for capital letters (i.e. A to B).
In: Computer Science
6.13 Lab: Patient Class - process an array of Patient objects
This program will create an array of 100 Patient objects and it will read data from an input file (patient.txt) into this array. Then it will display on the screen the following:
Finally, it writes to another file (patientReport.txt) a table as shown below:
Weight Status Report ==================== === ====== ====== ============= Name Age Height Weight Status ==================== === ====== ====== ============= Jane North 25 66 120 Normal Tim South 64 72 251 Obese . . . ==================== === ====== ====== ============= Number of patients: 5
Assume that a name has at most 20 characters (for formatting). Write several small functions (stand-alone functions). Each function should solve a specific part of the problem.
On each line in the input file there are four items: age, height, weight, and name, as shown below:
25 66 120 Jane North 64 72 251 Tim South
Prompt the user to enter the name of the input file. Generate the name of the output file by adding the word "Report" to the input file's name.
Display the output file's name as shown below:
Report saved in: patientReport.txt
If the user enters the incorrect name for the input file, display the following message and terminate the program:
Input file: patients.txt not found!
Here is a sample output:
Showing patients with the "Underweight" status: Tim South Linda East Paul West Victor Smith Tom Baker Showing patients with the "Overweight" status: none Showing patients with the "Obese" status: none Report saved in: patient1Report.txt
Main.cpp:
#include "Patient.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
const int MAX_SIZE = 100;
/* Write your code here:
declare the function you are going to call in this program
*/
int main()
{
Patient patArr[MAX_SIZE];
int size = 0;
string fileName;
cout << "Please enter the input file's name: ";
cin >> fileName;
cout << endl;
/* Write your code here:
function calls
*/
return 0;
}
/* Write your code here:
function definitions
*/
/*
OUTPUT:
*/
Patient.h:
/*
Specification file for the Patient class
*/
#ifndef PATIENT_H
#define PATIENT_H
#include <string>
using std:: string;
class Patient
{
private:
string name;
double height;
int age;
int weight;
public:
// constructors
Patient();
Patient(string name, int age, double height, int weight);
// setters
void setName(string name);
void setHeight(double height);
void setAge(int age);
void setWeight(int weight);
//getters
string getName() const;
double getHeight() const;
int getAge() const;
int getWeight() const;
// other functions: declare display and weightStatus
void display() const;
string weightStatus() const;
};
#endif
Patient.cpp:
/*
Implementation file for the Patient class.
*/
#include "Patient.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
/*******
This is the default constructor; it sets everything to 0 or
"".
*/
Patient::Patient()
{
name = "";
height = 0;
age = 0;
weight = 0;
}
/*******
This is an overloaded constructor.
It sets the variables according to the parameters.
*/
Patient::Patient(string name, int age, double height, int
weight)
{
this->name = name;
this->height = height;
this->age = age;
this->weight = weight;
}
void Patient::setName(string name)
{
this->name = name;
}
void Patient::setHeight(double height)
{
this->height = height;
}
void Patient::setAge(int age)
{
this->age = age;
}
void Patient::setWeight(int weight)
{
this->weight = weight;
}
string Patient::getName() const
{
return this->name;
}
double Patient::getHeight() const
{
return this->height;
}
int Patient::getAge() const
{
return this->age;
}
int Patient::getWeight() const
{
return this->weight;
}
/*******
This function displays the member variables
in a neat format.
*/
void Patient::display() const
{
cout << fixed;
cout << " Name: " << getName() << endl;
cout << " Age: " << getAge() << endl;
cout << " Height: " << setprecision(0) <<
getHeight() << " inches" << endl;
cout << " Weight: " << getWeight() << " pounds"
<< endl;
cout << "Weight Status: " << weightStatus() <<
endl;
}
/*******
This function calculates the BMI using the following formula:
BMI = (weight in pounds * 703) / (height in inches)^2
Then, it returns a string reflecting the weight status according to
the BMI:
<18.5 = underweight
18.5 - 24.9 = normal
25 - 29.9 = overweight
>=30 = obese
*/
string Patient::weightStatus() const
{
double bmi;
string stat = "";
if (height > 0)
{
bmi = (getWeight() * 703) / (getHeight() * getHeight());
if (bmi < 18.5)
{
stat = "Underweight";
}
else if (bmi >= 18.5 && bmi <= 24.9)
{
stat = "Normal";
}
else if (bmi >= 25 && bmi <= 29.9)
{
stat = "Overweight";
}
else
{
stat = "Obese";
}
}
return stat;
}
In: Computer Science
Consider how a star like the Sun changes after the Main Sequence. Put the following events in the correct order.
1. The outer layers of the star drift off into space creating a planetary nebula.
2. Helium fusion in the core of the star ends
3. The hot, dense core of the star is left behind as a white dward that slowly cools and dims over time.
4. The star shrinks slightly, compressing a shell of hydrogen surrounding the non-burning helium core.
5. The shell surrounding the non-burning carbon/oxygen core begins to fuse helium, and the shell outside of that fuses hydrogen.
6. The star's core becomes hot enough and dense enough to begin fusing helium to carbon and oxygen, causing it to collapse inward somewhat.
7. Shell hydrogen fusion is disrupted and the star shrinks slightly
8. Fusion of hydrogen to helium in the core of the star ends.
9. The star shrinks slightly, compressing a shell of helium surrounding the non-burning carbon/oxygen core, and a shell of hydrogen surrounding the region of helium
10. The star's surface becomes cooler and the star's luminosity increases; the star is now a "red giant."
11.Hydrogen shell fusion causes the outer layers of the star to expand outward.
12. The star's surface becomes cooler and the star's luminosity increases; the star is now an "asymptomatic giant."
13. Shell fusion of hydrogen and helium cause the outer layers of the star to expand outward.
14. The shell surrounding the non-burning helium core begins to fuse hydrogen
15. The star's surface becomes somewhat hotter and the star's luminosity decreases slightly; the star is now a "horizontal branch" star
In: Chemistry
According to Stanovich (2010), case studies and testimonials stand as isolated phenomena. They lack the comparative information necessary to prove that a particular theory or therapy is superior. However, it is wrong to cite a testimonial or a case study as a support for a particular theory or therapy. What might have happened in science if a psychologist or an individual cite a testimonial or a case study as a support for a particular theory or therapy? why, why not?
In: Psychology
A 14.7 μF capacitor is charged to a potential of 55.0 V and then discharged through a 75.0 Ω resistor.
(a) How long after discharge begins does it take for the capacitor to lose 90.0% of the following?
(i) its initial charge: _______s
(ii) its initial energy: _______s
(b) What is the current through the resistor at both times in part
(a)?
(i) at tcharge: ________A
(ii) at tenergy: ________A
In: Physics
In: Operations Management
Discuss what you know on the lean thinking,system and types of waste with giving examples .
You answer needs to be at least 8 lines and in paragraphs
In: Operations Management
Comparison of demographics between US and Philipines
United States Team's Assigned Country Age distribution - including
average age, birth rate and graph of population growth Income:
The Philippines and compare to united states-Marriage: civil or religious? Chosen or arranged? Divorce rate? Marriage customs (clothing, costs, celebrations)? Same sex marriages legal? 10. Shopping: how often? Where? Local, national or international suppliers? Set price or negotiated?
In: Operations Management
• Describe the process of managing stakeholder engagement and how to create and use an issue log.
In: Operations Management
4. Environment Recycling, Inc. must clean up a large automobile tire dump under a state environmental cleanup contract. Some of the activities can be crashed. The tasks, durations (in days), costs, predecessor relationships, the crash times, and costs associated with performing the activities at their original (normal) times and for the crash times are shown as follows:
|
Activity |
Immediate Predecessor |
Normal Time (days) |
Normal Cost ($) |
Crash Time |
Crash Cost ($) |
|
A |
-- |
6 |
1,000 |
5 |
1,200 |
|
B |
-- |
4 |
800 |
2 |
2,000 |
|
C |
A, B |
3 |
600 |
2 |
900 |
|
D |
B |
2 |
1,500 |
1 |
2,000 |
|
E |
C, D |
6 |
900 |
4 |
1,200 |
|
F |
E |
3 |
1,300 |
1 |
1,400 |
|
G |
E |
4 |
900 |
4 |
900 |
|
H |
G |
4 |
500 |
2 |
900 |
a. Find the total project completion time. (Show all work including finding the critical path).
b. Find the lowest cost solution if the state wants to complete the project two days early. State which activities need to be crashed and calculate the crashing cost for the total project.
In: Operations Management
Write the functions needed by the main function that is given.
multiply2nums should accept 2 values and return the product
(answer you get when you multiply).
greeting should accept one value and print an appropriate greeting
using that value. For example, if you sent "Steven" to the greeting
function, it should print "Hello, Steven"
DO NOT CHANGE ANYTHING IN main()
def main():
user = input("Please enter your name ")
greeting(user)
try:
num1 = int(input("Please enter an integer "))
num2 = int(input("please enter another integer "))
result = multiply2nums(num1,num2)
print("The product of your two numbers is ",result)
except:
print("Error found in input")
main()
In: Computer Science
In this assignment, you will implement a Polynomial linked list, the coefficients and exponents of the polynomial are defined as a node. The following 2 classes should be defined.
p1=23x 9 + 18x 7+3 1. Class Node ● Private member variables: coefficient (double), exponents (integer), and next pointer. ● Setter and getter functions to set and get all member variables ● constructor 2. Class PolynomialLinkedList ● Private member variable to represent linked list (head) ● Constructor ● Public Function to create a Node ● Public function to insert the Node to the linked list (sorted polynomial according to the exponent). ● Public function to print the polynomial in the elegant format: 23x 9 + 18x 7+3 ● Overloaded public function to allow adding two polynomials poly3=poly1+poly2 (23x 9 + 9x 7+3)+(2x 4+3x 7+8x 2 -6) =23x 9 +12 x 7+2x 4+8x 2 -3 ● Overloaded public function to allow negating (!) the sign of any polynomial poly3=!poly1 2x 4+3x 7+8x 2 -6 =- 2x 4 -3x 7+8x 2+6 ● Overloaded public function to allow multiplying two polynomials ● Public function to evaluate polynomial based on an input If x=1, then the value of this polynomial 2x 4+3x 7+8x 2 -6 should be 2(1) 4+3(1) 7+8(1) 2 -6 =7
Main menu to test the following tasks ○ cout << "1. Create polynomial \n"; ○ cout << "2. Print polynomial \n"; ○ cout << "3. Add two polynomilas \n"; ○ cout << "4. Negate polynomial \n"; ○ cout << "5. Multiply two polynomials \n "; ○ cout << "6. Evaluate polynomial \n "; ○ cout << "7. Exit \n";
In: Computer Science
1. A student attempts to identify an unknown compound by the method used in this experiment. She finds that when she heated a sample weighing 0.4862 g the mass barely changed, dropping to 0.4855 g. When the product was converted to a chloride, the mass went up, to 0.5247 g.
a. Is the sample a carbonate? NO
b. What are the two compounds that might be in the unknown? KHCO3 and NaHCO3
c. Write the chemical equation for the overall reaction that would occur when the original compound was converted to a chloride. If the compound is a hydrogen carbonate, use the sum of Reactions 1 and 2. If the sample is a carbonate, use Reaction 2. Write the equation for a sodium salt and then for a potassium salt.
d. How many moles of the chloride salt would be produced from one mole of original compound? _____
e. How many grams of the chloride salt would be produced from one molar mass of original compound? Molar masses: NaHCO3 84.008 g Na2CO3 105.99 g NaCl 58.44 g KHCO3 100.118 g K2CO3 138.21 g KCl 74.55 g
If a sodium salt, ____________ g original compound → ____________ g chloride I
f a potassium salt, ____________ g original compound → ____________ g chloride
f. What is the theoretical value of Q, if she has an Na salt? ____________ if she has a K salt? ____________
g. What was the observed value of Q? ____________
h. Which compound did she have as an unknown?
I have bolded my own answers. I need help with the rest, please show work!
In: Chemistry
Explain the difference between capital assets, capital investments, and capital budgeting.
In: Accounting
Discuss what is involved in directing and managing project work as part of project integration management, including the importance of producing promised deliverables, implementing solutions to issues, evaluating work performance data, and requesting changes to a project
In: Operations Management