Question

File Edit View History Bookmarks Tools Help Share GEP IIIA Moorhead, MN 10-Day Weathe X N NDSU Faculty and Staff | North x D

Please answer Question 4 WITH A C# PROGRAM!!!!!!

THANK YOU!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Done accordingly. Please uprate. Please comment for further help.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GradesFromFile
{
class Program
{
static void Main(string[] args)
{
//answers array
char[] answers = new char[]{'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'};
char[] studentResponse = new char[20]; //student response array
int[] correct = new int[20]; //correct answer array
int correctAnswersCount = 0; //total count of correct answers
  
//temporary variables
int j=0;
string line;

//file stream
System.IO.StreamReader file =
new System.IO.StreamReader(@"student.txt");

//reading file line by line
while ((line = file.ReadLine()) != null)
{
studentResponse[j] = line[0]; //storing char in array
j++; //increasing index
}
file.Close();//close file
//checking for correct answer
for (int i = 0; i < 20; i++)
{
if (answers[i] == studentResponse[i])
{
correct[i] = 1; //setting correct answer array to 1 if correct
correctAnswersCount++; //incrementing correct answer count
}
else
{
correct[i] = 0;//setting correct answer array to 0 if incorrect
}
}
//checking if answer count is greater than 15 then student will pass
if (correctAnswersCount >= 15)
{
Console.WriteLine("Student has passed.");
}
else
{
Console.WriteLine("Student has failed."); //for score less than 15 then failed
}
//displaying results
Console.WriteLine("Correct Answers :" + correctAnswersCount);
Console.WriteLine("Incorrect Answers :" + (20-correctAnswersCount));
Console.Write("Incorrect Answers :");
//displaying incorrect answers
for (int i = 0; i < 20; i++)
{
if (correct[i] == 0)
{
Console.Write((i+1)+" ");
}
}

Console.ReadKey();
}
}
}

student.txt

B
D
A
C
C
A
B
C
B
A
B
C
D
A
D
B
C
B
D
A

Output:

file:///C:/users/faraz/documents/visual studio 2012/Project Student has failed. Correct Answers :13 Incorrect Answers :7 Inco

file:///C:/users/faraz/documents/visual studio 2012/Project Student has passed. Correct Answers :15 Incorrect Answers :5 Inco

Add a comment
Know the answer?
Add Answer to:
Please answer Question 4 WITH A C# PROGRAM!!!!!! THANK YOU! File Edit View History Bookmarks Tools...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# Visual Studio -The local driver's license office has asked you to create an application that...

    C# Visual Studio -The local driver's license office has asked you to create an application that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1. B 2. D 3. A 4. A 5. C 6. A 7. B 8. A 9. C 10. D 11. B 12. C 13. D 14. A 15. D 16. C 17. C 18. B 19. D 20. A Your program should...

  • Using C++ 1. Driver's The local driver's license office has asked you to create an application...

    Using C++ 1. Driver's The local driver's license office has asked you to create an application that grades the written portion of the driver's license exam. The exam has 20 multiple-choice questions. Here are the correct answers 16. C 17.С 18. B 19. D 20. A 1. B 2. D 3. A 12. C 13. D 14. A 15. D 7.В 9.С 10. D 5. С Your program should store these correct answers in an array. It should ask the...

  • please only use import java.util.Scanner Driver's License Exam The local Driver's License Office has asked you...

    please only use import java.util.Scanner Driver's License Exam The local Driver's License Office has asked you to write a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1. A 2. D 3.В 4. B 5, C 6. В 7. A 8.В 9, C 10. D 12. C 13. D 14. B 15. D 16. С 18. A 19. D 20. B Your program should store...

  • Java: The local Driver's License Office has asked you to write a program that grades the...

    Java: The local Driver's License Office has asked you to write a program that grades the written portion of the driver's   license exam. The exam has 20 multiple choice questions.   Here are the correct answers:    1. B  6. A  11.B  16. C    2. D  7. B  12.C  17. C    3. A   8. A  13.D  18. B    4. A  9. C  14.A  19. D    5. C  10. D  15.D  20. A    Your program should store the correct answers in an array. (Store each question's answer in an element of a String array.) The program...

  • PYTHON CODE PLEASEEEEE. Driver’s License Exam 20PTS PYTHON AND FLOWCHART The local driver’s license office has...

    PYTHON CODE PLEASEEEEE. Driver’s License Exam 20PTS PYTHON AND FLOWCHART The local driver’s license office has asked you to design a program that grades the written portion of the driver’s license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1.B 6.A 11.B 16.C 2.D 7.B 12.C 17.C 3.A 8.A 13.D 18.B 4.A 9.C 14.A 19.D 5.C 10.D 15.D 20.A Your program should store these correct answers in an array. (Store each question’s correct answer in...

  • License test The Los Angeles driver's license office has asked you to create an application that...

    License test The Los Angeles driver's license office has asked you to create an application that grades the written portion of the drivers license test. The test has 15 multiple-choice questions. Here are the correct answers (You may create your own correct answers if you like) 1. C 2. D     3. B 4. A      5. C 6. D 7. B     8. A     9. C     10. D 11. A 12. C   13. D    14. A     15. B A student must answer 10...

  • Visual Basic zoow Driver's License Exam The local Registry of Motor Vehicles oflice has asked you to create an application that grades the written portion of the driver's license exam. The ex...

    Visual Basic zoow Driver's License Exam The local Registry of Motor Vehicles oflice has asked you to create an application that grades the written portion of the driver's license exam. The exam has 20 multiplc choice questions. Her ar the orrect answers to the questions: 6. A 7.13 8. A 9. C 10. D 16. С 12. C 13. D 14. A 15. D 2. D 3. A 5, C Your application should slore the correcl answers in an array....

  • JAVA Write a program that prompts the user to enter a file name, then opens the...

    JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...

  • Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a...

    Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a main function and three other functions called. readmarks , changemarks (, and writemarks() The program begins by calling the function readmarks () to read the input file marksin. txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks () the...

  • This program is part 1 of a larger program. Eventually, it will be a complete Flashcard...

    This program is part 1 of a larger program. Eventually, it will be a complete Flashcard game. For this part, the program will Prompt the user for a file that contains the questions – use getline(cin, fname) instead of cin >> fname to read the file name from the user. This will keep you in sync with the user’s input for later in the program The first line is the number of questions (just throw this line away this week)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT