Question

Please Help (Write C++ Program ONLY)-The attached file is a historical record of BCS courses offered...

Please Help (Write C++ Program ONLY)-The attached file is a historical record of BCS courses offered over the last four semesters. An X in one of the first four columns indicates that the course was offered in the semester that heads the column. A period (.) indicates that the course was not offered in that semester. Read the file and store the following information in two vectors:

An integer that encodes the semester offerings for the course as follows; Fall 15 counts 8, Spring 16 counts 4, Fall 16 counts 2, and Spring 17 counts 1. The offering code is the sum of these four numbers. A string which saves the course number and title that follows after the four offering columns. The two vectors are parallel in the sense that a given subscript selects offering information and the description for the same course. E.g the subscript 0 selects offering information and the description for the first course in the file.

After reading, encoding and saving all the course information, display the number of courses read. Then list on cout in the following order:

Courses offered Fall 2015 only
...
Courses offered Spring 2016 only
...
Courses offered Fall 2016 only
...
Courses offered Spring 2017 only
...

I pasted the text file below:-

F15 S16 F16 S17 
 .   .   .   .   BCS 101 Programming Concepts and Problem Solving
 X   X   X   X   BCS 102 Computer Concepts & App
 X   .   .   .   BCS 110-114 Introductory Special Topics in Computer Programming and Information Systems
 X   X   X   X   BCS 120 Foundations Comp. Pgm I
 X   X   X   X   BCS 130 Web Page Authoring
 .   .   .   .   BCS 136 Programming in COBOL I
 .   .   .   .   BCS 148 8086 and 8088 Assembler Programming I
 X   X   X   X   BCS 160 Computer, Society and Technology
 .   .   .   .   BCS 185 Programming in Visual Basic
 .   .   .   .   BCS 202 Computer Applications for Business/Sport Management
 X   X   X   X   BCS 208 Introduction to Networks
 X   X   X   X   BCS 209 Routing and Switching Essen
 X   X   X   X   BCS 215 UNIX Operating Systems
 X   X   X   X   BCS 230 Foundations Comp. Pgm II
 .   .   .   .   BCS 232 Electronic Commerce
 .   X   X   X   BCS 235 Javascript and jQuery
 .   .   .   .   BCS 237 Intermediate COBOL Programming
 X   X   X   X   BCS 240 Principles of Website Design
 X   .   .   .   BCS 250 Javascript and jQuery (deprecated)
 .   .   .   .   BCS 255 Operating Systems
 X   X   X   X   BCS 260 Database
 X   X   X   X   BCS 262 Data Communications
 .   .   .   .   BCS 285 Advanced Programming Visual Basic
 X   X   X   X   BCS 300 Management Info. Systems
 X   X   X   X   BCS 301 Systems Analysis & Design 
 .   .   .   .   BCS 302 Systems Analysis and Design II
 X   X   X   X   BCS 303 Advanced Website Devt (XML)
 .   .   .   .   BCS 305 Data Visualization
 X   .   X   .   BCS 311 Local Area Networks and Server Administration
 .   .   .   X   BCS 315 UNIX II
 X   X   X   X   BCS 316 PERL Programming
 X   X   X   X   BCS 317 ERP
 .   .   X   .   BCS 318 Virtualization and Cloud Computing
 X   X   X   X   BCS 320 Scaling Networks
 X   X   X   X   BCS 321 Connecting Networks
 .   .   .   .   BCS 340 Introduction to Algorithms
 X   X   X   X   BCS 345 JAVA Programming
 X   X   X   X   BCS 350 Web Database Development
 .   X   X   X   BCS 360 Programming in SQL
 X   X   X   X   BCS 370 Data Structures (Evenings)
 X   X   X   X   BCS 378 Information Security (Evenings)
 .   .   .   X   BCS 380 Adv. Database Programming
 .   X   .   X   BCS 390 Database Administration & Security
 .   .   .   .   BCS 405 IS Development Project Management
 .   .   .   .   BCS 410 Computer Architecture
 X   .   .   .   BCS 413 Advanced Enterprise Resource Planning
 .   .   .   .   BCS 415 Operating System Internals and Design
 .   .   .   .   BCS 420 Client/Server Computing
 .   X   X   X   BCS 421 Android Mobile Applications
 X   X   X   X   BCS 422 iOS Mobile Applications
 .   .   .   X   BCS 425 Decision Support Systems and Data Warehousing
 .   .   .   X   BCS 427 Game Programming
 X   X   X   X   BCS 430W Senior Project
 X   X   X   X   BCS 440 Senior Internship
 .   .   X   .   BCS 450 C# Programming
 X   X   .   X   BCS 450-BCS451 Special Projects (Virtualization)
 .   X   .   .   BCS 460W Ind Study- Writing Intensive
 .   .   .   .   BCS 460 Ind Study- Writing Intensive

Thank you so much for helping..

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


Solution: C+ solution for the given problem Note: make sure that the file is in correct format and it is in your project fold

for (int i 0; i<course.size )i++) if (valuei-2) cout<<course [i] <<endl; cout<xendl<<Courses offered spring 2017 only<<endl
cAusers 302330 documentsl visual studio 20121Projects\ Coursel DebuglCourse.exe Total number of courses is 59 Courses offered

Raw Paste Code:

#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include<sstream>
using namespace std;

int main()
{
std::ifstream readFile;
std::string path = "file.txt";
std::vector<string> course;
std::vector<int> value;
std::string a, b, c, d, e, BCS, code, title="",fileLines;
std::string X = "X";
int rcd, i, sum;
readFile.open(path);

if (!readFile)
{
cout << "file not found!!!!!"<< endl;
return -1;
}

i = 0;
rcd = 0;
while (getline(readFile,fileLines))
{
title="";
istringstream ss(fileLines);
sum = 0;

ss >>a >> b >> c >> d >> BCS >> code;
string t;
while(ss)
{
title=title+" "+t;
ss >>t;
}

BCS = code + " " + title;
if (a == X)
{
sum += 8;
}
if (b == X)
{
sum += 4;
}
if (c == X)
{
sum += 2;
}
if (d == X)
{
sum += 1;
}

course.push_back(BCS);
value.push_back(sum);
++i;
++rcd;
}
readFile.close();

cout<<"Total number of courses is " <<rcd<<endl;
//Display the required results
cout<<endl<<"Courses offered Fall 2015 only"<<endl;
for(int i=0;i<course.size();i++)
{

if(value[i]==8)
cout<<course[i]<<endl;
}

cout<<endl<<"Courses offered Spring 2016 only"<<endl;
for(int i=0;i<course.size();i++)
{

if(value[i]==4)
cout<<course[i]<<endl;
}

cout<<endl<<"Courses offered Fall 2016 only"<<endl;
for(int i=0;i<course.size();i++)
{

if(value[i]==2)
cout<<course[i]<<endl;
}

cout<<endl<<"Courses offered Spring 2017 only"<<endl;
for(int i=0;i<course.size();i++)
{

if(value[i]==1)
cout<<course[i]<<endl;
}


system("pause");
return 0;
}


Add a comment
Know the answer?
Add Answer to:
Please Help (Write C++ Program ONLY)-The attached file is a historical record of BCS courses offered...
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
  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • Use the SQL statements provided to create your tables. Write one SQL statement for each of...

    Use the SQL statements provided to create your tables. Write one SQL statement for each of the following problems. You can only use the conditions listed in the tasks. E.g., in task 1, you cannot manually look up pid of Information Systems undergraduate program. Here is the given code: drop table textbook_schedule cascade constraints; drop table textbook_author cascade constraints; drop table schedule cascade constraints; drop table course cascade constraints; drop table textbook cascade constraints; drop table author cascade constraints; drop...

  • c++ Write a program that computes and displays the tuition for courses offered at the University....

    c++ Write a program that computes and displays the tuition for courses offered at the University. First, the program should ask if the student has registered for a regular course or a course with a lab component. The user can enter the letter 'C' or 'c' for lecture course only, or the letter 'L' or 'l' for a laboratory course . Write a function called Menu, which takes no input parameters and returns a char value. Your main program will...

  • I need one file please (C++)(Stock Market) Write a program to help a local stock trading...

    I need one file please (C++)(Stock Market) Write a program to help a local stock trading company automate its systems. The company invests only in the stock market. At the end of each trading day, the company would like to generate and post the listing of its stocks so that investors can see how their holdings performed that day. We assume that the company invests in, say, 10 different stocks. The desired output is to produce two listings, one sorted...

  • And there was a buy-sell arrangement which laid out the conditions under which either shareholder could...

    And there was a buy-sell arrangement which laid out the conditions under which either shareholder could buy out the other. Paul knew that this offer would strengthen his financial picture…but did he really want a partner?It was going to be a long night. read the case study above and answer this question what would you do if you were Paul with regards to financing, and why? ntroductloh Paul McTaggart sat at his desk. Behind him, the computer screen flickered with...

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