INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO?
void readFile(Candidate candidates[]) – reads the elections.txt file, fills the candidates[] array. Hint: use substr() and find() functions. Set Score to 0.
void List(Candidate candidates[]) – prints the array of Candidate
structs. One candidate per one line, include all fields. Use setw()
to display nice looking list.
void displayCandidate(Candidate candidates[]) – prints the complete
information about the candidate
.
Candidate First(Candidate candidates[]) – returns single struct
element: candidate with highest score
Candidate Last(Candidate candidates[]) – returns single struct
element: candidate with lowest score
void Votes(Candidate candidates[]) – function sorts the
candidates[] array by number of votes, the order in candidates[]
array is replaced
void Scores(Candidate candidates[]) – calculates the percentage
score for each candidate. Use the following formula:
??????=(CandidateVotes)/(sum of votes)*100%
Correct line for the reference: F=John,L=Smith,V=3342
The line errors that your program needs to detect, are as follows:
incorrect token / separator, example in line 5: F=Steven,L=JohnV=4429 --- (comma missing) – lines with this error need to be ignored
space in token, example in line 3: F=Hillary,X=Clinton, V=1622 --- lines with this error need to be read, error fixed, data included in your dataset
empty line, example in line 6 – empty lines need to be ignored
Example Textfile
F=Michael,L=John,V=3342
F=Danny,L=Red,V=2003
F=Hillary,L=Clinton, V=1588
F=Albert,L=Lee,V=5332
F=Steven,L=JohnV=4429
*IMPORTANT* How would I do the readFile function? It says to check if the commas are present, and that the program will correct the line if there is white spaces. How do i use the find() function? Please be DETAILED in explanations of each part of code. Beginner Coder. *IMPORTANT*
Code Skeleton We HAVE to follow. How Would i go about using this skeleton? YOU CANNOT CHANGE FUNCTIONS OF VARIABLES, BUT YOU MAY ADD TO IT. THE CODE MUST HAVE WHAT IS LISTED IN THE SKELETON CODE:
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <fstream>
#include <string>
using namespace std;
struct Candidate {
string Fname;
string Lname;
int votes;
double Score;
};
const int MAX_SIZE = 100;
void readFile(Candidate[]);
void List(Candidate[]);
void Votes(Candidate[]);
void displayCandidate(Candidate);
Candidate First(Candidate[]);
Candidate Last(Candidate[]);
void Scores(Candidate[]);
int main() {
}
void readFile(Candidate candidates[]) {
string line;
ifstream infile;
infile.open("elections.txt");
while (!infile.eof()) {
getline(infile,line);
// your code here
}
infile.close();
}
void List(Candidate candidates[]) {
}
void Votes(Candidate candidates[]) {
}
void displayCandidate(Candidate candidates) {
}
Candidate First(Candidate candidates[]) {
}
Candidate Last(Candidate candidates[]) {
}
void Scores(Candidate candidates[]) {
}
Also, how do i make verticle columbs for the display?
In: Computer Science
Your Tasks
Step 1 Write the comments in the SnapCracklePop.java using the java doc style in zyBooks 3.8. See TODOa to TODOh.
Step 2 Complete the class definition, variable declarations, constructor, and all the methods by reading the instructions in SnapCracklePop.java. See TODO1 to TODO7. (DONE I NEED HELP WITH STEP 1)
1 //TODOa complete this javadoc comment
2 /**
3 * [The class description]
4 * @author [Your Name]
5 * @version 1.0
6 */
7
8 //TODO1: declare the SnapCracklePop class
9 class SnapCracklePop{
10 //TODOb Complete Comments
11 /**
12 * [Instance Variable Descriptions]
13 */
14
15 //TODO2 Declare private instance variables
16 //to store Snap, Crackle, and Pop values
17 private int snap;
18 private int crackle;
19 private int pop;
20
21 //TODOc complete comments
22 /**
23 * [Constructor Description]
24 * @param [param name] [what the param represents]
25 * @param [param name] [what the param represents]
26 * @param [param name] [what the param represents]
27 */
28
29 /* The constructor takes in three ints,
30 * which must be assigned to their instance variables and
initialized.
31 */
32
33 //TODO3 Write the constructor
34
35
36 //TODOe complete comments
37 /**
38 * [Method Description]
39 * @param [param name] [What the parameter represents]
40 * @return [What the method returns]
41 */
42 public SnapCracklePop(int snap, int crackle, int pop){
43 this.snap = snap;
44 this.crackle = crackle;
45 this.pop = pop;
46 }
47
48 /* playRound() is a helper method for playGame().
49 * It takes an int parameter representing the
50 * current round of play, and returns the
51 * String result for that specific round only.
52 */
53
54 //TODO4 implement the playRound method
55 String playRound(int round){
56 //set the string to empty
57 String output = "";
58 //if the current round number is multiple of snap
59 if(round % this.snap == 0){
60 output += "snap";
61 }
62 //if the current round number is multiple of crackle
63 if(round % this.crackle == 0){
64 output += "crackle";
65 }
66 //if the current round number is multiple of pop
67 if(round % this.pop == 0){
68 output += "pop";
69 }
70 //if the output is empty
71 if(output == ""){
72 output += round;
73 }
74
75 return output;
76 }
77 //TODOd complete comments
78 /**
79 * [Method Description]
80 * @param [param name] [What the parameter represents]
81 * @return [What the method returns]
82 */
83
84 /* playGame() takes a single parameter representing the rounds
and returns
85 * a String representing the result of the entire game. The
helper method
86 * playRound() may be useful here, so you may want to complete it
first.
87 */
88
89 //TODO5 implement the playGame method
90 String playGame(int rounds){
91 String result = "";
92 //set the number of snaps,crackles,pops to 0
93 int snaps = 0;
94 int crackles = 0;
95 int pops = 0;
96 for(int i = 1;i <= rounds;i++) {
97 //call the play round function
98 String current_result = playRound(i);
99 //if the current result string has snap in it
100 if(current_result.indexOf("snap") != -1){
101 // to get total number of snaps at last-increment it
102 snaps++;
103 }
104 //if the current result string has crackle in it
105 if(current_result.indexOf("crackle") != -1){
106 //to get total number of crackles at last-increment
crackles
107 crackles++;
108 }
109 //if the current result string has pop in it
110 if(current_result.indexOf("pop") != -1){
111 //to get total number of pops at last-increment pops
112 pops++;
113 }
114 result += current_result + "\n";
115 }
116 //add the values to the result with description
117 result += "Number of Snaps: " + snaps + "\n";
118 result += "Number of Crackles: " + crackles + "\n";
119 result += "Number of Pops: " + pops + "\n";
120 return result;
121 }
122
123 //Loop through the rounds of the game
124 //call playRound to handle the specific round
125 //return the total aggregated game results
126
127 //TODOf complete comments
128 /**
129 * [Method Description]
130 * @return [What this method returns]
131 */
132
133 //TODO6 implement the getSnap method
134 int getSnap(){
135 return this.snap;
136 }
137
138 //TODOg complete comments
139 /**
140 * [Method Description]
141 * @return [What this method returns]
142 */
143
144 //TODO7 implement the getCrackle method
145 int getCrackle(){
146 return this.crackle;
147 }
148 //TODOh complete comments
149 /**
150 * [Method Description]
151 * @return [What this method returns]
152 */
153
154 //TODO8 implement the getPop method
155 int getPop(){
156 return this.pop;
157 }
158 }
159
160
161
162 //end class
I finished to do 1-7 but i need help with to do a-h with the comments. please help! thanks!
In: Computer Science
CASE INCIDENT
What Should Wilma and Frank Do?
Frank and Wilma Rogers live in the Toronto area. Frank is a product engineer in the automotive industry and Wilma is a professor for a local community college. Wilma has been working on her doctorate for the last five years and is scheduled to graduate with her PhD in Business
Administration shortly. Wilma has just received an interesting telephone call and can’t wait to talk to Frank about it.Over dinner that night Wilma tells Frank about the phone call: a past boss of hers called to tell her about an open position at a university in Nunavut. As Wilma excitedly discusses the associate professor of business position and the opportunities it will bring, Frank is thinking to himself what a great opportunity it is, but that he doesn’t find the location appealing. He subsequently tells her this and nothing more is discussed. A week goes by and Wilma still finds herself yearning to know more about this position and wanting to apply. She calls Frank and explains this to him and he encourages her to apply. Wilma calls her former boss and applies for the position. Eventually she gets an offer. Wilma gives her notice at the college and within the next six months starts her new position. Wilma moves to Nunavut, but Frank stays in Toronto until he can find a job in Nunavut. A few more months go by and Frank has not been able to find a comparable job, so he pressures Wilma to consider moving back to Toronto and leaving her new position. Wilma is torn about what to do as she loves her new job but understands why Frank is frustrated.
Questions
1.According to Edgar Schein, what career anchors are driving Wilma’s and Frank’s careers at this point?
2.If Wilma wishes to stay in her new job, how could her employer assist her with this dilemma?
3.Is there anything Frank and Wilma should have done differently in your opinion? If so, what?
In: Psychology
Hello,
I have created the following code in C++. The goal of this code is to read 3 types of employee information(String/*Name*/, String/*Phone number*/,Int/*Office number*/, ) from a .txt file and store that information into an array which can be accessed by various functions. The code below is within a header file, and im trying to define some functions (within a .cpp file) of my class to carry out the following tasks.
I have already managed to define a couple functions, but I'm stuck on the two listed below and need help coding them.
Thank you.
CODE:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
const int SIZE = 25;
struct Phone
{
string employeeName;
string phoneExt;
int officeNumber;
};
class Directory
{
public:
Directory(string/*file name*/, int = SIZE/*max number
of employees*/);
void showPhone(string/*employee phone*/, int
/*employee office*/);
void showPhoneOffice(string/*Name*/) const;
void writeDirectory(ostream &)const;
void addEmployee(string/*Name*/, string/*Phone*/,
int/*Office*/); // this is second function I need help
defining
void showNoEmployees(ostream &) const; //This is
first function I need help defining
int getNoEmployees() const {return noEmployees;}
private:
Phone employees[SIZE];
int maxEmployees;
int noEmployees;
void findEmployee();
};
1. showPhoneOffice() that displays a string(a name) and int( a phone number). The function receives the string and int. It does not return a value. Displays the data or a meaningful error message if the string was not found
2. . addEmployee() that adds an employee(string/*Name*/,string/*Name*/,int/*Office Number*/) to the employee array. The function receives the employee’s string, string and int. It does not return a value. Ensure the employee is not already in an existing array and that the array is not full. You can assume valid data is passed.
In: Computer Science
Experiment: Lewis Dot Structures, Hybridization, and Shapes of Molecules and Ions
| Ion or Compound |
Number of Valence e^- in Structure |
Lewis Dot Structure | Number of e^- around Central Atom | Resonance Structure (If any, show changes) | Hybridization | Electronic Geometry | Molecular Geometry | Is the Compound Polar? |
| H2CO3 | ||||||||
|
S2O2^2- thiosulfate ion |
||||||||
| SF4 | ||||||||
| AlCl3 | ||||||||
| XeF4 | ||||||||
| H3PO3 |
In: Chemistry
Consider the following experiment. Pick a random integer from 1 to 10^12 .
(a) What is the probability that it is either a perfect square (1, 4, 9, 16, …) or a perfect cube (1, 8, 27, 64,…)?
(b) What is the probability that it is either a perfect fourth power (1, 16, 81, 256, …) or a perfect sixth power (1, 64, 729, 4096,…)?
In: Statistics and Probability
In an experiment, 26.0 g of metal was heated to 98.0°C and then quickly transferred to 150.0 g of water in a calorimeter. The initial temperature of the water was 20.5°C, and the final temperature after the addition of the metal was 32.5°C. Assume the calorimeter behaves ideally and does not absorb or release heat.
What is the value of the specific heat capacity (in J/g•°C) of the metal?
In: Chemistry
1.Balance the redox reaction first ( it is in basic medium)
ClO^-(aq) + CrO2^-(aq) -----> Cl^- (aq) +CrO4^-2(aq)
2. A titration experiment is set up to use .185M bleach (NaOCl) to analyze CrO2^-.If 50.0mL of the CrO2^-(aq) solution required 32.53mL of bleach to react to completion, what would you calculate as the molarity of the CrO2^- solution?
In: Chemistry
Using Ellman’s reagent, find the number of cysteines in a protein that has a concentration of 30 mg/ml solution with a molecular weight of 15,000 Da. Data-- 0.1 ml of the protein was reacted with the reagent and diluted to 10 ml and the absorbance at 412 nm was 1.4 A. Hint, first find the moles of protein used for the experiment, then calculate the moles of Ellman’s reagent that reacted
In: Chemistry
I know that there's big controversy between two groups of physicists:
One of the arguments of the second group is that there's no way to disprove the correctness of the string theory.
So my question is if there's any defined experiment that would disprove string theory?
In: Physics