Questions
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? void readFile(Candidate candidates[]) –...

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...

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

INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. ***DO NOT REPLY ANUNAGA.*** HOW TO DO?...

INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. ***DO NOT REPLY ANUNAGA.***

HOW TO DO?

*****IMPORTANT******* PLEASE READ CAREFULLY. WE HAVE TO DO WHAT THIS ASSIGNMENT DOES OR WE WILL MARKED OFF POINTS. IT DOES NOT HELP WHEN YOU CHANGE THE SKELETON TO YOU'RE PREFERENCE. YOU CAN ADD TO IT, BUT NOT CHANGE WHAT IS ALREADY THERE. THIS IS FOR A BASIC C++ LEVEL CLASS SO WE HAVE TO STICK TO BASIC C++ CODE. HOWEVER IT COULD BE WRONG IN TERMS OF WORKING CONDITIONS SO PLEASE HELP FIX THESE. *IMPORTANT*

Input format for each line: F=firstname,L=lastname,V=votes.
Read only valid lines into the array

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? IT IS A SKELETON, WHICH MEANS MORE VARIABLES AND SUCH CAN BE ADDED:

#include

#include

#include

#include

#include

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[]) {

}

In: Computer Science

Experiment: Lewis Dot Structures, Hybridization, and Shapes of Molecules and Ions Ion or Compound Number of...

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...

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...

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^-...

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...

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: those who support string theory...

I know that there's big controversy between two groups of physicists:

  1. those who support string theory (most of them, I think)
  2. and those who oppose it.

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

Suppose you want to test how fair is the coin. You conduct the following experiment. You...

Suppose you want to test how fair is the coin. You conduct the following experiment. You flip the 2 coins multiple times and observe HH - 23 times, HT - 24 times, TH - 37 times, and TT - 34 times. What is the Test Statistics to test the Null Hypothesis that the coin is fair against the alternative hypothesis that the coin is unfair?

In: Statistics and Probability