Assignment #2*: Build A Report Purpose: Exercise, use, Inputs, Outputs, and perform conditional evaluation Requirements: (Multiple classes/Multiple types of input) • Input: Report Owner’s full name and 7 numbers (at least one double and one integer) o The owner’s name cannot contain any special characters, blank spaces, or numbers • You must use an if statement and at least one switch statement in your program • You are not allowed to have static variables or methods in any class except for the class with the main method. • You have to have at least 2 classes • You are not allowed to use ArrayLists or Vectors, only primitive arrays or string arrays if you want. Application Operation: 1.) Input, via a question in the console, the report owner’s first name as a string and build the last name via input, one character at a time. a. Check, conditionally, to make sure the first name and last name don’t contain any numeric characters, numbers between 0 – 9. If it does you must remove it. The names can not contain any white space either or special characters. 2.) Input report name via a request from the console. 3.) Input, and display, the total of the numeric input after each input is entered. Average the numeric input, indicate lowest numeric input value and the highest numeric input value for the previous numeric inputs, before the next numeric input is asked for. (Example given in class) 4.) Have a program exit input, condition, value available (i.e. if you type -1 the program exits) 5.) Create and display a final report that should have the report name, owner and the following: Numeric output should appear as a table with the following columns: (columns should be underlined) a. Input Number b. Highest Number c. Lowest Number d. Total (by the row) e. Average Number 6.) At the end of the report you must have a grand total for the numeric entries
In: Computer Science
The comparative balance sheet of Whitman Co. at December 31, 2016 and 2015, is as follows:
|
1 |
Dec. 31, 2016 |
Dec. 31, 2015 |
|
|
2 |
Assets |
||
|
3 |
Cash |
$917,690.00 |
$964,930.00 |
|
4 |
Accounts receivable (net) |
?828,620.00 |
762,860.00 |
|
5 |
Inventories |
1,267,970.00 |
1,162,780.00 |
|
6 |
Prepaid expenses |
29,050.00 |
36,010.00 |
|
7 |
Land |
315,250.00 |
480,690.00 |
|
8 |
Buildings |
1,462,990.00 |
901,470.00 |
|
9 |
Accumulated depreciation-buildings |
(409,170.00) |
(382,690.00) |
|
10 |
Equipment |
511,480.00 |
453,680.00 |
|
11 |
Accumulated depreciation-equipment |
(142,100.00) |
(159,400.00) |
|
12 |
Total assets |
$4,781,780.00 |
$4,220,330.00 |
|
13 |
Liabilities and Stockholders’ Equity |
||
|
14 |
Accounts payable (merchandise creditors) |
$923,380.00 |
$958,540.00 |
|
15 |
Bonds payable |
269,000.00 |
0.00 |
|
16 |
Common stock, $25 par |
323,000.00 |
118,000.00 |
|
17 |
Paid-in capital: Excess of issue price over par—common stock |
771,200.00 |
558,000.00 |
|
18 |
Retained earnings |
2,495,200.00 |
2,585,790.00 |
|
19 |
Total liabilities and stockholders’ equity |
$4,781,780.00 |
$4,220,330.00 |
The noncurrent asset, noncurrent liability, and stockholders’ equity accounts for 2016 are as follows:
ACCOUNT Land
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 480,690 | |||
| Apr. | 20 | Realized $153,400 cash from sale | 165,440 | 315,250 |
ACCOUNT Buildings
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 901,470 | |||
| Apr. | 20 | Acquired for cash | 561,520 | 1,462,990 |
ACCOUNT Accumulated Depreciation––Buildings
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 382,690 | |||
| Dec. | 31 | Depreciation for year | 26,480 | 409,170 |
ACCOUNT Equipment
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 453,680 | |||
| 26 | Discarded, no salvage | 46,270 | 407,410 | |||
| Aug. | 11 | Purchased for cash | 104,070 | 511,480 |
ACCOUNT Accumulated Depreciation ––Equipment
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 159,400 | |||
| 26 | Equipment discarded | 46,270 | 113,130 | |||
| Dec. | 31 | Depreciation for year | 28,970 | 142,100 |
ACCOUNT Bonds Payable
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| May | 1 | Issued 20-year bonds | 269,000 | 269,000 |
ACCOUNT Common Stock $25 par
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 118,000 | |||
| Dec. | 7 | Issued 8,200 shares of common stock for $51 per share | 205,000 | 323,000 |
ACCOUNT Paid-In Capital in Excess of Par––Common Stock
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 558,000 | |||
| Dec. | 7 | Issued 8,200 shares of common stock for $51 per share | 213,200 | 771,200 |
ACCOUNT Retained Earnings
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 2,585,790 | |||
| Dec. | 31 | Net loss | 58,980 | 2,526,810 | ||
| 31 | Cash dividends | 31,610 | 2,495,200 |
Prepare a statement of cash flows, using the indirect method of presenting cash flows from operating activities. Refer to the Labels and Amount Descriptions list provided for the exact wording of the answer choices for text entries. Be sure to complete the heading of the statement. In the operating activities section, use the minus sign to indicate cash outflows, decreases in cash and a net cash outflow, if required. In the investing and financing activities section, use a minus sign only to indicate a NET cash outflow for the section.
Labels and Amount Descriptions
| Labels and Amount Descriptions | |
|---|---|
| Cash paid for acquisition of building | |
| Cash paid for dividends | |
| Cash paid for merchandise | |
| Cash paid for purchase of equipment | |
| Cash received from customers | |
| Cash received from issuance of bonds payable | |
| Cash received from issuance of common stock | |
| Cash received from land sold | |
| December 31, 2016 | |
| Decrease in accounts payable | |
| Decrease in accounts receivable | |
| Decrease in cash | |
| Decrease in inventories | |
| Decrease in prepaid expenses | |
| Decrease in salaries payable | |
| Depreciation | |
| For the Year Ended December 31, 2016 | |
| Gain on sale of investments | |
| Gain on sale of land | |
| Increase in accounts payable | |
| Increase in accounts receivable | |
| Increase in cash | |
| Increase in inventories | |
| Increase in prepaid expenses | |
| Increase in salaries payable | |
| Issuance of common stock for acquisition of building | |
| Issuance of common stock for purchase of equipment | |
| Issuance of common stock to retire bonds | |
| Loss on sale of investments | |
| Loss on sale of land | |
| Net cash flow from financing activities | |
| Net cash flow from investing activities | |
| Net cash flow from operating activities | |
| Net cash flow used for financing activities | |
| Net cash flow used for investing activities | |
| Net cash flow used for operating activities | |
| Net income | |
| Net loss |
Statement of Cash Flows
Prepare a statement of cash flows, using the indirect method of presenting cash flows from operating activities. Refer to the Labels and Amount Descriptions list provided for the exact wording of the answer choices for text entries. Be sure to complete the heading of the statement. In the operating activities section, use the minus sign to indicate cash outflows, decreases in cash and a net cash outflow, if required. In the investing and financing activities section, use a minus sign only to indicate a NET cash outflow for the section.
|
Whitman Co. |
|
Statement of Cash Flows |
|
1 |
Cash flows from operating activities: |
|||
|
2 |
||||
|
3 |
Adjustments to reconcile net loss to net cash flow from operating activities: |
|||
|
4 |
||||
|
5 |
||||
|
6 |
Changes in current operating assets and liabilities: |
|||
|
7 |
||||
|
8 |
||||
|
9 |
||||
|
10 |
||||
|
11 |
||||
|
12 |
||||
|
13 |
Cash flows from investing activities: |
|||
|
14 |
||||
|
15 |
||||
|
16 |
||||
|
17 |
||||
|
18 |
||||
|
19 |
Cash flows from financing activities: |
|||
|
20 |
||||
|
21 |
||||
|
22 |
||||
|
23 |
||||
|
24 |
||||
|
25 |
Cash at the beginning of the year |
|||
|
26 |
Cash at the end of the year |
In: Accounting
The comparative balance sheet of Whitman Co. at December 31, 2016 and 2015, is as follows:
|
1 |
Dec. 31, 2016 |
Dec. 31, 2015 |
|
|
2 |
Assets |
||
|
3 |
Cash |
$918,260.00 |
$965,110.00 |
|
4 |
Accounts receivable (net) |
828,050.00 |
761,830.00 |
|
5 |
Inventories |
1,268,550.00 |
1,163,510.00 |
|
6 |
Prepaid expenses |
28,760.00 |
35,720.00 |
|
7 |
Land |
315,810.00 |
479,900.00 |
|
8 |
Buildings |
1,463,300.00 |
900,740.00 |
|
9 |
Accumulated depreciation-buildings |
(408,350.00) |
(381,910.00) |
|
10 |
Equipment |
512,470.00 |
454,060.00 |
|
11 |
Accumulated depreciation-equipment |
(142,270.00) |
(159,730.00) |
|
12 |
Total assets |
$4,784,580.00 |
$4,219,230.00 |
|
13 |
Liabilities and Stockholders’ Equity |
||
|
14 |
Accounts payable (merchandise creditors) |
$922,360.00 |
$957,810.00 |
|
15 |
Bonds payable |
270,000.00 |
0.00 |
|
16 |
Common stock, $25 par |
316,000.00 |
116,000.00 |
|
17 |
Paid-in capital: Excess of issue price over par—common stock |
775,000.00 |
559,000.00 |
|
18 |
Retained earnings |
2,501,220.00 |
2,586,420.00 |
|
19 |
Total liabilities and stockholders’ equity |
$4,784,580.00 |
$4,219,230.00 |
The noncurrent asset, noncurrent liability, and stockholders’ equity accounts for 2016 are as follows:
ACCOUNT Land
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 479,900 | |||
| Apr. | 20 | Realized $152,430 cash from sale | 164,090 | 315,810 |
ACCOUNT Buildings
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 900,740 | |||
| Apr. | 20 | Acquired for cash | 562,560 | 1,463,300 |
ACCOUNT Accumulated Depreciation––Buildings
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 381,910 | |||
| Dec. | 31 | Depreciation for year | 26,440 | 408,350 |
ACCOUNT Equipment
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 454,060 | |||
| 26 | Discarded, no salvage | 47,260 | 406,800 | |||
| Aug. | 11 | Purchased for cash | 105,670 | 512,470 |
ACCOUNT Accumulated Depreciation ––Equipment
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 159,730 | |||
| 26 | Equipment discarded | 47,260 | 112,470 | |||
| Dec. | 31 | Depreciation for year | 29,800 | 142,270 |
ACCOUNT Bonds Payable
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| May | 1 | Issued 20-year bonds | 270,000 | 270,000 |
ACCOUNT Common Stock $25 par
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 116,000 | |||
| Dec. | 7 | Issued 8,000 shares of common stock for $52 per share | 200,000 | 316,000 |
ACCOUNT Paid-In Capital in Excess of Par––Common Stock
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 559,000 | |||
| Dec. | 7 | Issued 8,000 shares of common stock for $52 per share | 216,000 | 775,000 |
ACCOUNT Retained Earnings
| ACCOUNT NO. | ||||||
| Balance | ||||||
| Date | Item | Debit | Credit | Debit | Credit | |
| 2016 | ||||||
| Jan. | 1 | Balance | 2,586,420 | |||
| Dec. | 31 | Net loss | 53,460 | 2,532,960 | ||
| 31 | Cash dividends | 31,740 | 2,501,220 |
Prepare a statement of cash flows, using the indirect method of presenting cash flows from operating activities. Refer to the Labels and Amount Descriptions list provided for the exact wording of the answer choices for text entries. Be sure to complete the heading of the statement. In the operating activities section, use the minus sign to indicate cash outflows, decreases in cash and a net cash outflow, if required. In the investing and financing activities section, use a minus sign only to indicate a NET cash outflow for the section.
Labels and Amount Descriptions
| Labels and Amount Descriptions | |
|---|---|
| Cash paid for acquisition of building | |
| Cash paid for dividends | |
| Cash paid for merchandise | |
| Cash paid for purchase of equipment | |
| Cash received from customers | |
| Cash received from issuance of bonds payable | |
| Cash received from issuance of common stock | |
| Cash received from land sold | |
| December 31, 2016 | |
| Decrease in accounts payable | |
| Decrease in accounts receivable | |
| Decrease in cash | |
| Decrease in inventories | |
| Decrease in prepaid expenses | |
| Decrease in salaries payable | |
| Depreciation | |
| For the Year Ended December 31, 2016 | |
| Gain on sale of investments | |
| Gain on sale of land | |
| Increase in accounts payable | |
| Increase in accounts receivable | |
| Increase in cash | |
| Increase in inventories | |
| Increase in prepaid expenses | |
| Increase in salaries payable | |
| Issuance of common stock for acquisition of building | |
| Issuance of common stock for purchase of equipment | |
| Issuance of common stock to retire bonds | |
| Loss on sale of investments | |
| Loss on sale of land | |
| Net cash flow from financing activities | |
| Net cash flow from investing activities | |
| Net cash flow from operating activities | |
| Net cash flow used for financing activities | |
| Net cash flow used for investing activities | |
| Net cash flow used for operating activities | |
| Net income | |
| Net loss |
Statement of Cash Flows
Prepare a statement of cash flows, using the indirect method of presenting cash flows from operating activities. Refer to the Labels and Amount Descriptions list provided for the exact wording of the answer choices for text entries. Be sure to complete the heading of the statement. In the operating activities section, use the minus sign to indicate cash outflows, decreases in cash and a net cash outflow, if required. In the investing and financing activities section, use a minus sign only to indicate a NET cash outflow for the section.
|
Whitman Co. |
|
Statement of Cash Flows |
|
1 |
Cash flows from operating activities: |
|||
|
2 |
||||
|
3 |
Adjustments to reconcile net loss to net cash flow from operating activities: |
|||
|
4 |
||||
|
5 |
||||
|
6 |
Changes in current operating assets and liabilities: |
|||
|
7 |
||||
|
8 |
||||
|
9 |
||||
|
10 |
||||
|
11 |
||||
|
12 |
||||
|
13 |
Cash flows from investing activities: |
|||
|
14 |
||||
|
15 |
||||
|
16 |
||||
|
17 |
||||
|
18 |
||||
|
19 |
Cash flows from financing activities: |
|||
|
20 |
||||
|
21 |
||||
|
22 |
||||
|
23 |
||||
|
24 |
||||
|
25 |
Cash at the beginning of the year |
|||
|
26 |
Cash at the end of the year |
In: Accounting
Read the article that you will find entitled “The experience of nurses working with nursing students in a hospital: a phenomenological investigation.” Give a brief summary about the research study. Select one of the mid-range nursing theorists that can be used as the theoretical framework of the study and justify your answer. You must include at least two paragraphs in your analysis.
Objective:
This article explores the experiences of nurses working with
Spanish nursing students in a hospital.
Methods:
a qualitative phenomenological approach and a convenience sample
were used. Twenty-two nurses belonging to a public hospital in
Spain were included in the study. The data were collected through
unstructured and semi-structured interviews, and analyzed using
Giorgi's proposal. The Consolidated Criteria for Qualitative
Research Reports were followed.
Results:
Three main themes describe the experience of nurses: "The
relationship of the nurse with the nursing students" Most nurses
emphasize the importance of the first contact with the students and
consider that the attitude of the students is essential. "The
definition of the role of the student in clinical practice"; it is
necessary to unify the role and interventions of the nurse to avoid
misguiding the students and to establish priorities in clinical
practice. "Build bridges between clinical environments and the
University"; the need to establish common ground and connections
between the university and the hospital's clinical services was
emphasized. Nurses think that the educational program should also
be designed by the clinical services.
Conclusions:
Understanding the meanings of female nursing students with nurses
can provide a deeper insight into their expectations.
Descriptors: Nursing Education; Hospitals; Students in Nursing;
Qualitative research
In: Nursing
Consider the following relational schema:
Salerep(sales_rep_ID, name, address, commission, rate)
Customer(customer_number, name, address, balance, credit_limit, sales_rep_ID)
Part(part_number, part_description, on_hand, class, warehouse, price)
Orders(order_number, order_date, customer_number)
Orderlilne(order_number, part_number, number_order)
Write SQL statements for the following queries:
a) Produce a list showing part_number, part_description, on_hand, and price sorted by part_description.
b) List customer’s name followed by order_number, part_description, and number_order.
c) List names of customers who have ordered the most expensive item(Hint: Use a nested SQL query to determine thehighest price.)
d) List the names of the sale_reps who have sold the most number of part “123”.(Hint: Use a nested SQL query for the FROM clause)
In: Computer Science
For this programming assignment, you will use your previous code that implemented a video game class and objects with constructors. Add error checking to all your constructors, except the default constructor which does not require it. Make sure that the high score and number of times played is zero or greater (no negative values permitted). Also modify your set methods to do the same error checking. Finally add error checking to any input requested from the user.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class VideoGame {
private:
string name;
int highScore;
int numOfPlays;
public:
VideoGame() {
name = "NA";
highScore = 0;
numOfPlays = 0;
}
VideoGame(string n, int score, int num) {
name = n;
highScore = score;
numOfPlays = num;
}
VideoGame(string n) {
name = n;
highScore = 0;
numOfPlays = 0;
}
VideoGame(const VideoGame &p2)
{
name = p2.name;
highScore = p2.highScore;
numOfPlays = p2.numOfPlays;
}
void setName(string n) {
name = n;
}
void setHighScore(int score) {
highScore = score;
}
void setNumOfPlays(int num) {
numOfPlays = num;
}
string getName() {
return name;
}
int getHighScore() {
return highScore;
}
int getNumOfPlays() {
return numOfPlays;
}
};
string inputName() {
string n;
cout << "Enter name of video game: ";
getline(cin >> ws, n);
return n;
}
int inputHighScore() {
int score;
cout << "Enter current high score of game: ";
cin >> score;
return score;
}
int inputNumOfPlays() {
int num;
cout << "Enter number of times game is played: ";
cin >> num;
return num;
}
void output(VideoGame game) {
cout << game.getName() << endl
<< "Played " << game.getNumOfPlays() << " times (HIGH SCORE " << game.getHighScore() << ")" << endl;
}
int main() {
VideoGame game1, game2, game3("VideoGame 3");
game1.setName(inputName());
game1.setHighScore(inputHighScore());
game1.setNumOfPlays(inputNumOfPlays());
cout << "\nGame1" << endl;
output(game1);
cout << endl;
game2.setName(inputName());
game2.setHighScore(inputHighScore());
game2.setNumOfPlays(inputNumOfPlays());
cout << "\nGame2" << endl;
output(game2);
cout << "\nGame3" << endl;
output(game3);
VideoGame game4 = game2;
cout << "\nGame4" << endl;
output(game4);
return 0;
}
In: Computer Science
Create a C++ program to simulate an art gallery:
Title of painting
Artists first name
Artists last name
Address street number
Address street name
Address city
Address state
Address zip
Artists website
Category
Number
Should print to a file all of the paintings by category and in alphabetical order based on the artist's last name.
This is an example txt file but the program will be tested with multiple files with different numbers of paintings:
Full Fathom Five
Jackson
Pollock
16
Woodbury
Springs
NY
11937
www.jacksonpollock.com
Abstract
978-3-16-148410-0
Impression, Sunrise
Claude
Monet
361
Sunflower
Giverny
France
27620
www.claudemonet.com
Impressionism
968-3-16-158420-0
A Sunday Afternoon on the Island of La Grande Jatte
Georges
Seurat
89
Longview
Paris
France
75006
www.gseurat.com
Pointillism
918-3-15-152420-0
In: Computer Science
In Java, design and implement a class called Cat. Each Cat class will contain three private variables - an integer representing its speed, a double representing its meowing loudness, and a String representing its name. Using the Random class, the constructor should set the speed to a random integer from 0 to 9, the meowing loudness to a random double, and the name to anything you want; the constructor should take no parameters. Write “get” and “set” methods for each variable, and one that prints all the variables. Finally, write a main method to test the methods in the class. The three variables must be private.
Then design and implement a class called CatOwner. Each CatOwner will have three private variables: a String representing the owner name, an integer representing how much cat food is left, and a cat; each cat should be an instance of the Cat class. The constructor can name the CatOwner anything you want, and the supply of food should be a random number greater than or equal to 10 and less than 50. Each cat’s name should be set to “Tinkles.” The constructor for CatOwner should take no parameters. Write “get” and “set” methods for the owner’s name, the food supply, and all the properties of the cat; also write a feedCat method that decreases the food supply by 1 and prints that the cat was fed. Next, write a method to print all class variables. Finally, write a main method to test your methods.
Design a driver class which instantiates two CatOwner objects. Next, perform the following five steps:
1. Change the name of the first cat owner to “John Doe” and his
dog’s name to “Whiskers.” Change the name of the second cat owner
to “George Washington.”
2. Increase the meowing loudness of the first cat owner’s cat by
.1, and set the speed of the second cat owner’s cat to 5.
3. Double the food supply of the first cat owner, and set the food
supply of the second to 25.
4. Have the first cat owner feed his cat three times, and have the
second cat owner feed his cat twice.
5. Print out all the information for both cat owners.
In: Computer Science
// staff should be coming in to
// campus, or staying at home. Only part of the code is here.
// It bases the decision based on a points system by asking
the
// user a set of questions and keeping track of how many
times
// it gets a yes response back.
//
// The code implements policy by assigning a weight to each of
the
// categories of symptoms/risk factors
// 1) Mild Symptoms (1pt each)
// 2) Severe Symptoms (2pt each)
// 3) Recent exposure (3pt each)
// 4) Risk factors (3pt each)
//
// This file implements only the checks FOR ( 1
MILD) symptoms.
//
// There are 5 errors in this code.
//
// ~-~-~- ~-~-~-~-~ ~-~-~-~-~ ~-~-~-~-~ ~-~-~-~-~ ~-~-~-~-~
~-~-~-~-~ ~-~-~-~-~|
import java.util.Scanner;
public class Fragment1 {
public static final int MILD_SYMPTOMS = 1;
// This method gets the next line of input from the
scanner and
// Checks to see if it is "yes" (in either upper or
lower case)
// If it is, it returns the number provided as the
second argument
// else, it returns 0.
public static int checkAndAdd(Scanner input, int
score){
String answer = input.nextLine();
if (answer.equalsIgnoreCase("yes")){
return 0;
} else {
return score;
}
}
// This method asks the user about a list of symptoms
and uses
// the checkAndAdd method to check the answers.
// Tt sums up a score based on MILD_SYMPTOMS for each
yes answer
// and returns the total.
public static int checkMildSymptoms(String name,
Scanner input) {
int score = 0;
System.out.println(name+ ", do you have chills? (yes/no)");
score--;
System.out.println(name+ ", do you have diarrhea? (yes/no)");
score += checkAndAdd(input, MILD_SYMPTOMS);
System.out.println(name+ ", do you have sore throat?
(yes/no)");
score += checkAndAdd(input, MILD_SYMPTOMS)
System.out.println{name+ ", do you have body aches?
(yes/no)");
score += checkAndAdd(input, MILD_SYMPTOMS);
System.out.println(name+ ", do you have headache? (yes/no)");
score += check&Add(input, MILD_SYMPTOMS);
return score;
}
public static void main(String[] args) {
int totalScore = 0; // Tabulates the likelihood of infection
int totalRisk = 0; // Tabulates the high risk categories
String name=""; // Stores the name so we can be friendly
// Setup the scanner so we can prompt the user for answers
Scanner input = new Scanner(System.in);
System.out.println("Your total score is "+
checkMildSymptoms(name,input)
+ " points");
}
}
In: Computer Science
*I JUST WANT A GENERAL WALKTHROUGH OF HOW TO DO THIS. PSEUDOCODE IS FINE. THANK-YOU. THIS IS IN C THE PROGRAMMING LANGUAGE.*
The program will require the following structure:
struct _data {
char *name;
long number;
};
The program will require command line arguments:
int main(int argv, char **argc) {
Where argv is the number of arguments and argc is an array
holding the arguments (each is a string). Your program must catch
any case where no command line arguement was provided and print
a warning message (see below).
You MUST include/use the following functions, defined as follows:
int SCAN(FILE *(*stream)) - this function will open the file/stream
and return an integer indicating how many lines there are. Note that
I need to pass stream, which is a pointer, by reference. So I am
passing this as a pointer to a pointer.
struct _data *LOAD(FILE *stream, int size) - this function will
rewind file, create the dynamic array (of size), and read in the
data, populating the _data struct dynamic array. Note that stream
is passed by value this time. The function then returns the populated
array of struct.
void SEARCH(struct _data *BlackBox, char *name, int size) - this function
will get the dynamic array of struct passed to it, the name we are looking
for, and the size of the array. This function will then search the dynamic
array for the name. See below for examples.
void FREE(struct _data *BlackBox, int size) - this function will free up
all of the dynamic memory we allocated. Take note of the number of times
malloc/calloc were called, as you need to free that same number.
Finally, the data file will be called hw5.data and will be formatted as:
ron 7774013
jon 7774014
tom 7774015
won 7774016
HINTS:
------
Functions that will make things much easier:
getline()
feof()
strtok()
atoi()
SAMPLE RUNS:
------------
Case 1 - No command line argument provided.
[yourname@chef junk]$ ./CS230-5
*******************************************
* You must include a name to search for. *
*******************************************
Case 2 - Provided name is NOT in the list.
[yourname@chef junk]$ ./CS230-5 joe
*******************************************
The name was NOT found.
*******************************************
Case 3 - Provided name is in the list.
*******************************************
The name was found at the 2 entry.
*******************************************
In: Computer Science