1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aksik [14]
3 years ago
15

Open the"stateData3.c" program and try to understand how the tokenization works. If you open the input file "stateData.txt", you

can clearly seethat a comma separates the state name and its population. The tokenizer portion of the programs separates each line into two tokens and stores them into two different arrays. You need to display the arrayelements such that each line has a state and itspopulation. Also calculate the total population of USA.Then,examine the portion of the code how it writes the array elements into a binary datafile.You need to write similar logic where it writes the array elements into a text file "stateDataOutput2.txt". Please check the syntax and usage of fprintf(); and use that here.
Engineering
1 answer:
babymother [125]3 years ago
5 0

Answer:

Kindly see explaination

Explanation:

Code

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define size 200

int main(void)

{

int const numStates = 50;

char tempBuffer[size];

char tmp[size];

char fileName[] = "stateData.txt"; // Name of the text file (input file) which contains states and its populations

char outFile[] = "stateDataOutput1.txt"; // Output file name

// Open the input file, quit if it fails...

FILE *instream = fopen(fileName, "r");

/* Output File variable */

FILE *opstream;

if(instream == NULL) {

fprintf(stderr, "Unable to open file: %s\n", fileName);

exit(1);

}

//TODO: Open the output file in write ("w") mode

/* Opening output file in write mode */

opstream = fopen(outFile, "w");

//TODO: Read the file, line by line and write each line into the output file

//Reading data from file

while(fgets(tmp, size, instream) != NULL)

{

//Writing data to file

fputs(tmp, opstream);

}

// Close the input file

fclose(instream);

//TODO: Close the output file

/* Closing output file */

fclose(opstream);

return 0;

}

You might be interested in
An engineer measures a sample of 1200 shafts out of a certain shipment. He finds the shafts have an average diameter of 2.45 inc
Vadim26 [7]

Answer: 78.89%

Explanation:

Given : Sample size : n=  1200

Sample mean : \overline{x}=2.45

Standard deviation : \sigma=0.07

We assume that it follows Gaussian distribution (Normal distribution).

Let x be a random variable that represents the shaft diameter.

Using formula, z=\dfrac{x-\mu}{\sigma}, the z-value corresponds to 2.39 will be :-

z=\dfrac{2.39-2.45}{0.07}\approx-0.86

z-value corresponds to 2.60 will be :-

z=\dfrac{2.60-2.45}{0.07}\approx2.14

Using the standard normal table for z, we have

P-value = P(-0.86

=P(z

Hence, the percentage of the diameter of the total shipment of shafts will fall between 2.39 inch and 2.60 inch = 78.89%

7 0
3 years ago
A distillation column is initially designed to separate a mixture of toluene and xylene at around ambient temperature (say, 100°
weeeeeb [17]

Answer:

Purchase cost= 87056

Bar module cost= 292725

Explanation:

solution is attached below

6 0
4 years ago
Write a C program that will update a bank balance. A user cannot withdraw an amount ofmoney that is more than the current balanc
GarryVolchara [31]

Answer:

Explanation:

Sample output:

BANK ACCOUT PROGRAM!

----------------------------------

Enter the old balance: 1234.50

Enter the transactions now.

Enter an F for the transaction type when you are finished.

Transaction Type (D=deposit, W=withdrawal, F=finished): D

Amount: 568.34

Transaction Type (D=deposit, W=withdrawal, F=finished): W

Amount: 25.68

Transaction Type (D=deposit, W=withdrawal, F=finished): W

Amount: 167.40

Transaction Type (D=deposit, W=withdrawal, F=finished): F

Your ending balance is $1609.76

Program is ending

Code to copy:

// include the necessary header files.

#include<stdio.h>

// Definition of the function

float withdraw(float account_balance, float withdraw_amount)

{

// Calculate the balace amount.

float balance_amount = account_balance - withdraw_amount;

// Check whether the withdraw amount

// is greater than 0 or not.

if (withdraw_amount > 0 && balance_amount >= 0)

{

// Assign value.

account_balance = balance_amount;

}

// return account_balance

return account_balance;

}

// Definition of the function deposit.

float deposit(float account_balance, float deposit_amount)

{

// Check whether the deposit amount is greater than zero

if (deposit_amount > 0)

{

// Update account balance.

account_balance = account_balance + deposit_amount;

}

// return account balance.

return account_balance;

}

int main()

{

// Declare the variables.

float account_balance;

float deposit_amount;

float withdrawl_amount;

char input;

// display the statement on console.

printf("BANK ACCOUT PROGRAM!\n");

printf("----------------------------------\n");

// prompt the user to enter the old balance.

printf("Enter the old balance: ");

// Input balance

scanf("%f", &account_balance);

// Display the statement on console.

printf("Enter the transactions now.\n");

printf("Enter an F for the transaction type when you are finished.\n");

// Start the do while loop

do

{

// prompt the user to enter transaction type.

printf("Transaction Type (D=deposit, W=withdrawal, F=finished): ");

// Input type.

scanf(" %c", &input);

// Check if the input is D

if (input == 'D')

{

// Prompt the user to input amount.

printf("Amount: ");

// input amount.

scanf("%f", &deposit_amount);

// Call to the function.

account_balance=deposit(account_balance,deposit_amount);

}

// Check if the input is W

if (input == 'W')

{

printf("Amount: ");

scanf("%f", &withdrawl_amount);

// Call to the function.

account_balance = withdraw(account_balance,withdrawl_amount);

}

// Check if the input is F

if (input == 'F')

{

// Dispplay the amount.

printf("Your ending balance is $%.2f\n", account_balance);

printf("Program is ending\n");

}

// End the while loop

} while(input != 'F');

return 0;

}

the picture uploaded below shows the program screenshot.

cheers, i hope this helps.

5 0
3 years ago
The following are the results of a sieve analysis. U.S. sieve no. Mass of soil retained (g) 4 0 10 18.5 20 53.2 40 90.5 60 81.8
il63 [147K]

Answer:

a.)

US Sieve no.                         % finer (C₅ )

4                                                  100

10                                                95.61

20                                               82.98

40                                               61.50

60                                               42.08

100                                              20.19

200                                              6.3

Pan                                               0

b.) D10 = 0.12, D30 = 0.22, and D60 = 0.4

c.) Cu = 3.33

d.) Cc = 1

Explanation:

As given ,

US Sieve no.             Mass of soil retained (C₂ )

4                                            0

10                                          18.5

20                                         53.2

40                                         90.5

60                                         81.8

100                                        92.2

200                                       58.5

Pan                                        26.5

Now,

Total weight of the soil = w = 0 + 18.5 + 53.2 + 90.5 + 81.8 + 92.2 + 58.5 + 26.5 = 421.2 g

⇒ w = 421.2 g

As we know that ,

% Retained = C₃ = C₂×\frac{100}{w}

∴ we get

US Sieve no.               % retained (C₃ )               Cummulative % retained (C₄)

4                                            0                                           0

10                                          4.39                                      4.39

20                                         12.63                                     17.02

40                                         21.48                                     38.50

60                                         19.42                                     57.92

100                                        21.89                                     79.81

200                                       13.89                                     93.70

Pan                                        6.30                                      100

Now,

% finer = C₅ = 100 - C₄

∴ we get

US Sieve no.               Cummulative % retained (C₄)          % finer (C₅ )

4                                                     0                                          100

10                                                  4.39                                      95.61

20                                                 17.02                                     82.98

40                                                 38.50                                    61.50

60                                                 57.92                                    42.08

100                                                79.81                                     20.19

200                                                93.70                                   6.3

Pan                                                 100                                        0

The grain-size distribution is :

b.)

From the diagram , we can see that

D10 = 0.12

D30 = 0.22

D60 = 0.12

c.)

Uniformity Coefficient = Cu = \frac{D60}{D10}

⇒ Cu = \frac{0.4}{0.12} = 3.33

d.)

Coefficient of Graduation = Cc = \frac{D30^{2}}{D10 . D60}

⇒ Cc = \frac{0.22^{2}}{(0.4) . (0.12)} = 1

3 0
3 years ago
A heat pump is used to warm a building in the winter. This system implements an ideal vapor-compression cycle with R-134a as the
Marrrta [24]

Answer:

See attachment for detailed answer.

Explanation:

Download pdf
5 0
3 years ago
Other questions:
  • 5.5 A scraper with a 275 hp diesel engine will be used to excavate and haul earth for a highway project. An evaluation of the jo
    10·1 answer
  • A student is using a 12.9 ft ramp to raise an object 6 ft above the ground.
    5·1 answer
  • What is an isentropic process?
    7·1 answer
  • What is the steady-state value of the output of a system with transfer function G(s)= 6/(12s+3), subject to a unit-step input?
    5·1 answer
  • You are an engineer at company XYZ, and you are dealing with the need to determine the maximum load you can apply to a set of bo
    13·1 answer
  • The iron-blade plow allowed humans to increase food production during<br> what age?
    8·1 answer
  • A long corridor has a single light bulb and two doors with light switch at each door.
    12·1 answer
  • name the process by which mild steel can be converted into high carbon steel and explain it briefly ?​
    12·1 answer
  • How can you drop two eggs the feweHow can you drop two eggs the fewest amount of times, without them breaking? ...st amount of t
    13·2 answers
  • Instructions: For each problem, identify the appropriate test statistic to be use (t test or z-test). Then compute z or t value.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!