Please can someone double-check my answers?
1) A ball with a mass of 0.15 kg has a velocity of 5m/s. It strikes a wall perpendicularly and bounces off straight back with a velocity of 3 m/s. The ball underwent a change in momentum of?
1.20 kg*m/s
2) What braking force is supplied to a 3,000 kg car traveling with a velocity of 35 m/s that is stopped in 12 seconds?
F=8750 N
3) A 0.1 kg baseball is thrown with a velocity of 35 m/s. The batter hits it straight back with a velocity of 60 m/s. What is the magnitude of the average impulse exerted on the ball by the bat?
9.5 N*s
4) A 1 kg object is moving with a velocity of 6 m/s to the right. It collides and sticks to a 2 kg object moving with velocity of 3 m/s in the same direction. How much Kinetic energy is lost in the collision?
3J
5) A 2 kg mass moving with a velocity of 7 m/s collides elastically with a 4 kg mass moving in the opposite direction at 4 m/s. The 2 kg mass reverses direction after the collision and has new velocity of 3 m/s. What is the velocity of the 4 kg mass?
1 m/s
6) A mass of 3 kg is attached to a massless spring with a force constant 500 N/m. The mass rests on a horizontal frictionless surface. The system is compressed a distance of 30 cm from the springs initial position and then released. The momentum of the mass when the spring passes its equilibrium position is?
8660.25m/s
7) Can an object have energy without having momentum? Explain.
Yes an object can have energy without having momentum. For example, a rock that is at the top of a cliff has potential energy since it's not moving but there is no momentum.
8) Can an object have momentum without having energy? Explain.
No object that has momentum also has energy. This is because if the velocity is not then the kinetic energy is also not 0 momentum is a vector, but energy is a scalar.
9) An object of mass 2 kg has a linear momentum of 6 kg. m /s. What is this objects Kinetic energy?
9J
10) A box with a mass of 2 kg accelerates in a straight line from 4 m/s to 8 m/s due to the application of a force whose duration is 0.5 seconds. Find the average strength of this force?
16N
11) A 45 kg. girl is sitting on a seesaw 0.6 m from the balance point. How far, on the other side, should a 60 kg. boy sit so that the seesaw will remain in balance?
0.45m
12) A solid cylinder consisting of an outer radius R1 and an inner radius R2 is pivoted on a frictionless axle as shown. A string is wound around the outer radius and is pulled to the right with a force F1 = 3N. A second string is wound around the inner radius and is pulled down with a force F2 = 5N. If R1 = 0.75 m and R2 = 0.35m, what is the net torque acting on the cylinder?
-0.5Nm
15) An object of mass 0.5 kg., moving in a circular path of radius 0.25 m, experiences a centripetal acceleration of constant magnitude 9 m/s2 . What is the objects angular speed?
6 rad/sec
16) An object, originally at rest begins spinning under uniform angular acceleration. In 10 seconds, it completes an angular displacement of 60 rad. What is the value of its angular acceleration?
1.2 rad/s^2
17) The moment of Inertia of a solid uniform sphere of mass m and radius R is given by the equation I = (2/5) mR2 . Such a sphere is released from rest at the top of an inclined plane of height h= 10 m, length L, and the incline angle Ω. If the sphere rolls without slipping, find the linear speed at the bottom of the incline.
11.83m/s
18) An object spins with angular velocity 10 rad/s. If the objects moment of Inertia increases by a factor of 2 without the application of an external torque, what will be the object’s new angular velocity?
1/2 angular velocity (w)
19) A 0.05 kg ball is thrown upward from the ground with an initial velocity of 30 m/s. At its maximum height, the magnitude of the balls acceleration is?
9.80 m/s^2
20) A 15 Newton force is applied to a mass M that is adjacent to a wall, as shown. If the mass is 2 kg, the force that the wall exerts on the mass is equal to?
15N
In: Physics
1. Read the following description: Charlotte and Chandler are expecting their first child in two months. They have been told they are having a boy. They live in a rural part of Mississippi. They have been together as a couple for a little over a year. They are not married and both are not sure whether or not they would like to be in the future. The couple lives together in a small, one bedroom house. Charlotte is 21 years-old and is a student at the local community college. She had a full-time job at a retail store that she recently quit. She is considered a good student, as usually makes As and Bs. She plans to continue to pursue her degree after the baby is born. Chandler is 22 years-old, and never finished high school. He has no plans to earn his GED and he works odd-jobs within the construction field. Although neither of them had health insurance, Charlotte signed up for Medicaid benefits when she found out she was pregnant. Now on Medicaid, she routinely sees her OB/GYN. Both Charlotte and Chandler are emotionally close to their own parents. They both come from middle class families. All of their parents work and are not able to financially contribute to the couple’s income on a regular basis. Although their parents are emotionally supportive to them, they don’t give them a lot of guidance about how to handle things in life or how to deal with their situation as a couple. Charlotte and Chandler have been arguing a lot over money and role expectations. Chandler takes on extra jobs to earn more money. Charlotte doesn’t like him taking extra jobs because it takes away from the time they can spend together. Charlotte wants Chandler to stay home with her more as she feels lonely and sad due to the changes that are occurring to her body and her life. Chandler spends more time away from the house to get away from the negativity he feels when he is around Charlotte. This leads Charlotte feeling even lonelier. She reacts by fighting with Chandler when he is home, which drives him further away. Both feel they are under tremendous stress that the other one doesn’t understand. Although Charlotte wants to stop, she has continued to smoke cigarettes throughout the pregnancy. She also worries about gaining too much weight. She often skips meals and eats snacks throughout the day including chips, crackers, and cheese. She also drinks large amounts of Mountain Dew. She has stopped taking her prenatal vitamins since they make her feel more nauseated. Her doctor has informed her that she needs to take care of herself better by getting rest, eating well, and watching her blood pressure. The doctor is unaware of her unhealthy habits. He has been concerned that Charlotte has not gained weight throughout the pregnancy like expected. She in turn is hoping that the baby will be born early so that she won’t have to gain as much weight or go through the pain of labor that she is anticipating. Neither, Charlotte or Chandler, are prepared for when the baby comes home. Both are the youngest in their own families and have very limited experience with newborns and children in general. Neither has taken a child preparation class or read any books about parenting. They both think they will “wing” it, but are really depending on their own mothers to guide them. When asked about caregiving, neither of them has made any realistic plans for the near future.
From what you have learned this semester (coming from e-text and Power Points), compose a 2-3 page typed report (single-spaced, no larger than a 12 point font) that addresses the following:
Discuss infant mortality rates and main causes of death during infancy. Identify the protective factors (things are favorable for healthy development) for this child based on the hypothetical couple description above
Identify the risk factors (things that are unfavorable for healthy development) for this child based on this hypothetical couple description above.
Discuss how the factors you identified are related to infant mortality rates.
Identify what other things must be considered that the hypothetical description did not address.
State your opinion on whether or not you think this child would live to see his first birthday. Explain/support your position.
In: Psychology
Calculate (i)Cost of Production and Profitability Statement .(ii) Cash flow Statement.(iii)Calculate the cost of Capital; (iv) NPV of the Project;(v)DSCR.
Zinc Unit Installed Capacity First Year Second Year
Third Year…
Tonnes 1000000 750000 800000
1000000
SRevenue Projection : Zinc is expected to be sold at Rs per ton Rs2.1 lakh.
Cost of the Project: The cost of the project works out as
below:
a) Fixed Assets or Long Term Loan: Rs 3145 crores
b) Working Capital : The working capital requirements were Rs 431
crores at 75% capacity; Rs 459.73 crores at 80% capacity and Rs
574.67 crores at full capacity utilization. Interest rate for
working capital were @12.5 %.
Means of Financing: The project would be financed by equity of Rs
942 crores and rest by term loan financing amounting to Rs 2203
crores . Interest on term loan was @11.50 %. The company’s share is
listed in NSE . The risk-free rate of return is 8.00% assumed by
the company and the market rate of return is 18%. The Beta of the
company, as reported in the pink press was 1.17. Marginal tax rate
of the company is @ 27 %. The project does not enjoy any tax
exemption. It is expected the project will be implemented in an
years time.
Life of the Project : For all estimation purposes life of the project would be 8 (eight) years. The project enjoys 2 (two)years moratorium in terms of repayment of instalment payment .
In rest of the six years, instalments of the principal will be paid uniformly. However interest payment will be from the first year of operation.
Salvage Value of the Project : Rs 310.
Manpower of the Project: Since company is already running a plant of similar type and of bigger capacity , the company is confident to draw competent human resources required for the project.
Availability of Raw Material : The company is in possession of mine rights of Zinc Mine , there will be no difficulty to obtain needed raw material .
Technology and Process Knowhow :The company will be using Bayer–Hall-Herout commercial technology, for the production of Zinc.
Fuel Usage: To ensure reliable low-cost power for the units operations and to achieve self-sufficiency of energy needs, the company proposes to set up captive power plants (CPPs) to cater to the power requirements of its smelters and mines. Besides a large part of coal for the CPPs is high GCV imported coal. The price of coal since remains to be volatile the company is examining critically ,setting up installed thermal captive power plants (CPPs). As of now it would buy power from outside.
Risk Analysis- an indicative list only :(a)Changes in the market prices of Zinc, could adversely affect the results of operations;(b)Operating results are affected by movements in exchange rates; (c) The company’s energy requirements are met by power supply of electricity boards , any changes in the state government’s policy could increase production costs. (d) The company has to obtain a steady supply of Zinc ore at reasonable costs otherwise results of operations may be affected.
Domestic Industry Outlook: Domestic Zinc consumption has been witnessing strong growth spurred by investments and industrial growth. The outlook for future demand remains upbeat as economic activity in key Zinc consuming sectors continued to be fast paced. The company estimates with this capacity expansion its share in global market will be around 7%.
Project Implementation :A combination of cutting-edge technology-driven equipment and know-how of global mining experts will help us develop the mines. These initiatives will ensure high productivity levels at low costs, enabling us to maintain our position as one of the lowest-cost producers globally.
Revenues and Cost Structure (%)
Cost Components as % of Revenue
Raw Material 0.049
Salaries 0.034
Finance Cost 0.14
Depreciation 0.18
Power Fuel Water 0.050
Other Expenses 0.250
Sub Total .703
In: Finance
Case 3-2 Rite Aid Inventory Surplus Fraud
Occupational fraud comes in many shapes and sizes. The fraud at Rite Aid is one such case. In February 2015, VP Jay Findling pleaded guilty to fraud. VP Timothy Foster pleaded guilty to making false statements to authorities. On November 16, 2016, Foster was sentenced to five years in prison and Findling, four years. Findling and Foster were ordered to jointly pay $8,034,183 in restitution. Findling also forfeited and turned over an additional $11.6 million to the government at the time he entered his guilty plea. In sentencing Foster, U.S. Middle District Judge John E. Jones III expressed his astonishment that in one instance at Rite-Aid headquarters, Foster took a multimillion dollar cash pay-off from Findling, then stuffed the money into a bag and flew home on Rite Aid’s corporate jet.1
The charges relate to a nine-year conspiracy to defraud Rite Aid by lying to the company about the sale of surplus inventory to a company owned by Findling when it was sold to third parties for greater amounts. Findling would then kick back a portion of his profits to Foster. Foster’s lawyer told Justice Jones that, even though they conned the company, the efforts of Foster and Findling still earned Rite Aid over $100 million “instead of having warehouses filled with unwanted merchandise.” Assistant U.S. Attorney Kim Daniel focused on the abuse of trust by Foster and persistent lies to the feds. “The con didn’t affect some faceless corporation, Daniel said, “but harmed Rite Aid’s 89,000 employees and its stockholders.” Findling’s attorney, Kevin Buchan, characterized his client as “a good man who made a bad decision.” “He succumbed to the pressure. That’s why he did what he did and that’s why he’s here,” Buchan said during sentencing.
Findling admitted he established a bank account under the name “Rite Aid Salvage Liquidation” and used it to collect the payments from the real buyers of the surplus Rite Aid inventory. After the payments were received, Findling would send lesser amounts dictated by Foster to Rite Aid for the goods, thus inducing Rite Aid to believe the inventory had been purchased by J. Finn Industries, not the real buyers. The government alleged Findling received at least $127.7 million from the real buyers of the surplus inventory but, with Foster’s help, only provided $98.6 million of that amount to Rite Aid, leaving Findling approximately $29.1 million in profits from the scheme. The government also alleged that Findling kicked back approximately $5.7 million of the $29.1 million to Foster.
Assume you are the director of internal auditing at Rite Aid and discover the surplus inventory scheme. You know that Rite Aid has a comprehensive corporate governance system that complies with the requirements of Sarbanes-Oxley, and the company has a strong ethics foundation. Moreover, the internal controls are consistent with the COSO framework. Explain the steps you would take to determine whether you would blow the whistle on the scheme applying the requirements of AICPA Interpretation 102-4 that are depicted in Exhibit 3.11. In that regard, answer the following questions.
Questions
Explain the following concepts in the context of the case and how it relates to individual and organizational factors that contribute to fraud:
Rationalizations for unethical actions.
Stakeholder effects.
Ethical dissonance.
Sometimes good people do bad things.
Assume you are the director of internal auditing and have uncovered the fraud. What would you do and why?
Assume, instead, that you are the audit engagement partner of KPMG and are the first to uncover the fraud. You approach management of the firm and discuss making the necessary adjustments. Top management tells you not to press the issue because the firm doesn’t want to rock the boat with one of its biggest clients. What would you do and why?
In: Accounting
this is a four part question and I am lost: the question is at the top and the data follows:
a. Response: Hemoglobin Model: Glucoseb.
General Regression Analysis: Hemoglobin versus Glucose
Regression Equation
Hemoglobin = 4.44742 + 0.0241019 Glucose
Coefficients
Term Coef SE Coef T P
Constant 4.44742 0.124943 35.5957 0.000
Glucose 0.02410 0.001017 23.6982 0.000
Summary of Model
S = 0.831988 R-Sq = 53.00% R-Sq(adj) = 52.91%
PRESS = 348.310 R-Sq(pred) = 52.51%
Analysis of Variance
Source DF Seq SS Adj SS Adj MS F P
Regression 1 388.744 388.744 388.744 561.603 0.0000000
Glucose 1 388.744 388.744 388.744 561.603 0.0000000
Error 498 344.718 344.718 0.692
Lack-of-Fit 135 167.864 167.864 1.243 2.552 0.0000000
Pure Error 363 176.854 176.854 0.487
Total 499 733.462
Fits and Diagnostics for Unusual Observations
Obs Hemoglobin Fit SE Fit Residual St Resid
14 12 10.0150 0.121499 1.98503 2.41175 R X
17 6 7.7976 0.043273 -1.79759 -2.16352 R
22 12 9.6775 0.108033 2.32246 2.81529 R X
55 12 9.3883 0.096666 2.61168 3.16049 R X
74 6 7.7735 0.042763 -1.77349 -2.13445 R
84 11 9.5088 0.101378 1.49117 1.80576 X
88 6 7.8699 0.044908 -1.86990 -2.25078 R
99 11 8.3278 0.057982 2.67217 3.21961 R
133 6 7.7976 0.043273 -1.79759 -2.16352 R
138 6 7.8217 0.043801 -1.82169 -2.19261 R
142 10 8.1109 0.051299 1.88909 2.27490 R
152 10 7.9904 0.047940 2.00959 2.41943 R
159 6 7.8940 0.045485 -1.89400 -2.27988 R
161 11 8.5447 0.065267 2.45525 2.96019 R
165 6 7.8699 0.044908 -1.86990 -2.25078 R
173 6 7.7012 0.041344 -1.70118 -2.04725 R
189 6 7.8217 0.043801 -1.82169 -2.19261 R
192 10 9.7739 0.111861 0.22605 0.27419 X
202 10 8.0145 0.048588 1.98549 2.39052 R
218 10 8.1109 0.051299 1.88909 2.27490 R
223 12 9.7739 0.111861 2.22605 2.70010 R X
229 6 7.8458 0.044346 -1.84579 -2.22169 R
237 11 9.2196 0.090137 1.78040 2.15260 R
241 10 8.2073 0.054180 1.79268 2.15927 R
243 11 9.2196 0.090137 1.78040 2.15260 R
278 10 8.0627 0.049921 1.93729 2.33271 R
282 6 7.8458 0.044346 -1.84579 -2.22169 R
312 6 7.7012 0.041344 -1.70118 -2.04725 R
321 12 12.1600 0.209508 -0.16004 -0.19876 X
368 12 9.5811 0.104223 2.41887 2.93042 R X
375 11 8.9786 0.080983 2.02142 2.44121 R
385 11 10.1837 0.128295 0.81632 0.99305 X
470 6 7.8940 0.045485 -1.89400 -2.27988 R
471 6 7.9181 0.046077 -1.91810 -2.30898 R
475 6 7.7735 0.042763 -1.77349 -2.13445 R
483 6 7.9181 0.046077 -1.91810 -2.30898 R
499 10 8.2796 0.056437 1.72037 2.07256 R
R denotes an observation with a large standardized residual.
X denotes an observation whose X value gives it large leverage.
Normplot of Residuals for Hemoglobin
Residual Histogram for Hemoglobin
Response: Glucose Model: carb_intake
In: Statistics and Probability
*********C++ Program************
This assignment is the continuation of project 4, with the modification and improvement with the following modifications:
7/3 + 1/3 = 8/3
7/3 - 1/3 = 2
7/3 * 1/3 = 7/9
7/3 / 1/3 = 7
7/3 is:
> 1/3 according to the overloaded > operator
>= 1/3 according to the overloaded < operator
Press any key to continue
******Fraction.h*********
#ifndef FRACTION_H
#define FRACTION_H
#include <iostream>
using namespace std;
class Fraction {
// not
fully commented
public:
Fraction(int = 0, int = 1); // default
constructor
Fraction add(const Fraction&); //addition
function
Fraction subtract(const Fraction&); //subtraction
function
Fraction multiply(const Fraction&);
//multiplication function
Fraction division(const Fraction&); //division
function
void display(ostream& out) const; //display
function
void printFractionAsFloat(ostream& out) const;
//print the fraction as a float function
private:
int numerator;
int denominator;
void reduce();
// utility function, reduce
to lowest terms
};
#endif
*****Fraction.cpp*******
#include <cmath>
#include "Fraction.h"
using namespace std;
//------------------------------ Fraction
------------------------------------
// default constructor: parameters are numerator and denominator
respectively
// if the number is negative, the negative is always stored in the
numerator
Fraction::Fraction(int n, int d)
{
numerator = (d < 0 ? -n : n);
denominator = (d < 0 ? -d : d);
reduce();
}
//(a)--------------------------------- add
--------------------------------------
// overloaded +: addition of 2 Fractions, current object and
parameter
Fraction Fraction::add(const Fraction& a)
{
Fraction t;
t.numerator = a.numerator * denominator +
a.denominator * numerator;
t.denominator = a.denominator * denominator;
t.reduce();
return t;
}
//(b)------------------------------ subtract
------------------------------------
// subtraction of 2 Fractions, current object and parameter
//overload operator -
Fraction Fraction::subtract(const Fraction& a)
{
Fraction t;
int num = this->numerator; //the value of numerator
equals the num
int denom = this->denominator; //the value of
denominator equals the denom
int second_num = a.numerator; //second numerator
equals the second num
int second_denom = a.denominator; //the second
denominator equals the second denom
int overall_numerator = (num* second_denom - denom *
second_num); //equation for the numerator
int den = (denom * second_denom); //equation for the
denominator
t.numerator = overall_numerator; //setting the value
of the overall numerator to t.numerator
t.denominator = den; //setting the value of the den to
t.denominator
t.reduce(); //reduce the fration
return t; //return the fraction value
}
//Multpilication function that overrides the multiplication
function
Fraction Fraction::multiply(const Fraction& a)
{
Fraction t; //declared variable
t.numerator = a.numerator * numerator; //simple
equation for multiplication
t.denominator = a.denominator * denominator;
t.reduce();
return t;
}
//division function that overrides the / operator
Fraction Fraction::division(const Fraction& a)
{
Fraction t;
t.numerator = numerator * a.denominator;
t.denominator = a.numerator * denominator;
t.reduce();
return t;
}
//the display function the displays the fraction as numerator/denominator
void Fraction::display(ostream& out) const
{
out << numerator << "/" <<
denominator;
}
//the float function that turns the fration into a decimal
void Fraction::printFractionAsFloat(ostream& out)
const
{
if (denominator == 0)
{
out << "The fraction has a
denomintor of 0!";
}
else
out << float(numerator) /
float(denominator);
}
void Fraction::reduce()
{
int i;
i = abs(denominator * numerator); //set the value of
integer i to the denominator multiplied by the
//absolute value of numerator
while (i > 1) //will cntinue through the loop until
i is equal equal to or less than one
{
if ((denominator % i == 0)
&& (numerator % i == 0))
{
denominator /=
i;
numerator /=
i;
}
i--;
}
}
In: Computer Science
I did the previous steps and now im at 6 and 7. I can not figure it out. It is a calculator code, and this part we need to make it password protected. The user is asked to enter in a username and password, and if the password is the backwards of the username you get into the calulator code (that i already have finished below). Use strings and arrays to hold the username and password (maybe use something like gets() and fgets()) and use a do while loop to reverse the password and use strcmp() to compair the two words, if they are the same the calculator will unlock showing my calculator menu, else something like "invalid password" appears on the screen, and asking the user if they desire to try again. Use <stdio.h> and <string.h>
6. Now I want to make sure that nobody uses my calculator without authorization. So a user will have to enter a username and password, which if correct will show the welcome page and menu to the user else it will print the message like “Incorrect password. Authorization denied”. The correct password will be the reverse of the username. So after the user enters the username and password, you will check if the reverse of the password is the username. You will use a while loop to reverse your password. And you will you strcmp() to compare the username the user entered to the reverse of the password.
7. Below are the snapshots of the desired output screen. Figure 1: The above shows the program asking for username and password. We have entered a name in the username and the reverse of that name as the password. Figure 2: If the logging is successful you should print a message “Successful login” and then the menu should be displayed.
#include<stdio.h>
int main() {
char c;
do {
printf("Welcome to my
calculator\nPlease look at the menu below for your
calculations\n");
printf("1. Addition\n2.
Subtraction\n3. Multiplication\n4. Division\n5. Modulus \n6.
Factorial \n");
int n, x, y, f, i;
unsigned long long a = 1;
printf("Please press your choice
from 1-6: ");
scanf_s("%d", &n);
getchar();
switch (n) {
case 1:
printf("Enter
first number: ");
scanf_s("%d",
&x);
getchar();
printf("Enter
second number: ");
scanf_s("%d",
&y);
getchar();
printf("%d + %d
= %d \n", x, y, x + y);
break;
case 2:
printf("Enter
first number: ");
scanf_s("%d",
&x);
getchar();
printf("Enter
second number: ");
scanf_s("%d",
&y);
getchar();
printf("%d - %d
= %d \n", x, y, x - y);
break;
case 3:
printf("Enter
first number: ");
scanf_s("%d",
&x);
getchar();
printf("Enter
second number: ");
scanf_s("%d",
&y);
getchar();
printf("%d * %d
= %d \n", x, y, x*y);
break;
case 4:
printf("Enter
first number: ");
scanf_s("%d",
&x);
getchar();
printf("Enter
second number: ");
scanf_s("%d",
&y);
getchar();
if (y == 0)
{
printf("Division by 0 is not allowed\n");
}
else {
printf("%d / %d = %d \n", x, y, x / y);
}
break;
case 5:
printf("Enter
first number: ");
scanf_s("%d",
&x);
getchar();
printf("Enter
second number: ");
scanf_s("%d",
&y);
getchar();
if (y == 0)
{
printf("Division by 0 is not allowed\n");
}
else {
printf("The Modulus of %d and %d is: %d \n", x,
y, x%y);
}
break;
case 6:
printf("Enter
your number: ");
scanf_s("%d",
&f);
getchar();
if (f <
0)
printf("Error! Factorial of a negative number
does not exist\n");
else {
for (i = 1; i <= f; i++) {
a *= i;
}
printf("Factorial of %d = \n", f, a);
}
break;
default:
printf("Error!!
Enter a valid option 1-6\n");
}
printf("Do you want to Continue?
(Y/N): ");
scanf_s(" %c", &c);
getchar();
} while (c != 'N');
return 0;
}
In: Computer Science
C++
Download Lab10.cpp . In this file, the definition of the class personType has given. Think of the personType as the base class.
Lab10.cpp is provided below:
#include <iostream>
#include <string>
using namespace std;
// Base class personType
class personType
{
public:
void print()const;
//Function to output the first name and last name
//in the form firstName lastName.
void setName(string first, string last);
string getFirstName()const;
string getLastName()const;
personType(string first = "", string last = "");
//Constructor
//Sets firstName and lastName according to the parameters.
//The default values of the parameters are null strings.
//Postcondition: firstName = first; lastName = last
private:
string firstName; //variable to store the first name
string lastName; //variable to store the last name
};
void personType::print() const
{
cout << "Person FirstName="<<firstName << "
LastName=" << lastName<< endl;
}
void personType::setName(string first, string last)
{
firstName = first;
lastName = last;
}
string personType::getFirstName() const
{
return firstName;
}
string personType::getLastName() const
{
return lastName;
}
//constructor
personType::personType(string first, string last)
{
firstName = first;
lastName = last;
}
// --------------------Start your code from here
//--------------------driver program
int main()
{
personType person1("Lisa", "Regan");
doctorType doctor1("Sarah", "Conner", "Dentist");
patientType patient1("Sam", "Fire",200,100,1916);
billType b1;
b1.setDoctor(doctor1);
b1.setPatient(patient1);
b1.setCharge(250.66);
cout << "<personType> Printing...\n";
person1.print();
cout << endl;
cout << "<doctorType> Printing...\n";
doctor1.print();
cout << endl;
cout << "<patientType> Printing...\n";
patient1.print();
cout << endl;
cout << "<billType> Printing...\n";
b1.print();
cout << endl;
return 0;
}
Question:
● Derive the class doctorType, inherited from the class
personType, with an additional class member variable member to
store a doctor’s specialty(string type) Then, implement following
class member function prototypes.
doctorType(string,string,string);//Firstname Lastname
Specialty
doctorType();//Default constructor
void setSpecialty(string);//Set doctor specialty
string getSpecialty()const;// Get doctor specialty
void print()const;//Display doctor information the same as given
output format
● Derive the class patientType, inherited from the class
personType, with additional class
member variables to store a patient’s id , age , and dob (Date of
birth)(All are integer ).
Then, implement following class member function prototypes.
patientType(string, string, int, int, int);//Firstname Lastname id
age dob
patientType();Default constructor
void setId(int);//Set patient id
void setage(int);//Set patient age
void setDob(int);//Set patient DOB
int getId()const;//Get patient id
int getage()const;//Get patient
int getDob()const;//Get patient DOB
void print()const; //Display patient information the same as given
output format
● Design a class billType, with class member variables to store
a patient’s information
( patientType ), the patient’s doctor’s information ( doctorType ),
and the hospital
charges( double ). Then, implement following class member function
prototypes.
billType(doctorType &, patientType &); // Constructor
void setCharge(double);//Set hospital charges
double getCharge()const;//Get hospital charges
void print()const;//Display a bill information the same as given
output format
Use the provided driver program to test your program. You should get the same output
Output:
<perspnType> Printing...
Person FirstName=Lisa LastName=Regan
<doctorType> Printing...
Doctor FirstName=Sarah LastName=Conner Specialty=Dentist
<patientType> Printing...
Patient FirstName=Sam LastName=Fire Id=200 Age=100 DOB=1916
<billType> Printing..
Patient FirstName=Sam LastName=Fire Id=200 Age=100 DOB=1916
Patient's doctor FirstName=Sarah LastName=Conner Specialty=Dentist
Hospital charge=250.66$
Press any key to continue...
In: Computer Science
For this assignment, you will apply what you learned in analyzing Java™ code so far in this course by writing your own Java™ program. The Java™ program you write should do the following:
Complete this assignment by doing the following:
Program Summary: This program demonstrates these basic Java
concepts:
* - defining variables of different types
* - if-then and if-then-else logic
* - constructing a string to display onscreen
* - switch logic
*
* To complete this assignment, you will add code where indicated.
The
* behavior of your completed assignment should be to accept an
input
* value for the number of sides of a two-dimensional figure. Based
on that value,
* your code should display the type of figure that corresponds to
the number of polygon angles
* indicated (3=triangle, 4=rectangle, etc.)
*
* Here are the specific requirements:
*
* After the user types in a value from 3 to 5 inclusive (i.e., 3,
4, or 5):
*
* 1. Your code determines whether the input value is out of range
(less than 3 or more than 5)
* and, if so, displays a meaningful error message on the screen and
ends the program.
*
* 2. Because you will be comparing a single expression (the input
value) to multiple constants (3, 4, and 5),
* your code should use a switch statement to display the following
message onscreen:
*
* If user inputs 3, onscreen message should say "A triangle has 3
sides."
* If user inputs 4, onscreen message should say "A rectangle has 4
sides."
* If user inputs 5, onscreen message should see "A pentagon has 5
sides."
*
* 3. Be sure to test your program. This means running your program
multiple
* times with test values 3, 4, 5, as well as at least two values
that fall outside that range
* (one lower than the lowest and one higher than the highest) and
making sure
* that the correct message displays for each value you input. Also
be sure
* that running your program does not cause any compiler
errors.
***********************************************************************/
package week2codingassignment;
import java.util.Scanner;
public class PRG420Week2_CodingAssignment {
public static void main(String[] args) {
String userInputStringOfAngles; // Declare a variable of type
String to capture user input
int numberOfAngles; // Declare a variable of type int to hold the
converted user input
Scanner myInputScannerInstance = new Scanner(System.in); //
Recognize the keyboard
System.out.print("Please type the integer 3, 4, or 5 and then press
Enter: "); // Prompt the user
userInputStringOfAngles= myInputScannerInstance.next(); // Capture
user input as string
numberOfAngles = Integer.parseInt(userInputStringOfAngles); //
Convert the string to a number in case this will be useful
later
// LINE 1. CODE TO DETERMINE WHETHER USER INPUT IS OUT OF BOUNDS
GOES HERE
// LINE 2. SWITCH CODE TO PRINT CORRECT "SHAPE" MESSAGE BASED ON
USER INPUT GOES HERE
}
}
In: Computer Science
In: Computer Science