Question

c++ Each menu choice will call a different function. If you did not put the Math...

c++

Each menu choice will call a different function. If you did not put the Math Break code into its own function before, you will do it in this lab. You will write function stubs for options 3, 4, and 5. You will implement options 1 and 2 for Lab 3. Display an error message if an invalid option is entered. You can assume they will enter an integer option when prompted.

Option 1: Reads 17 records out of a file. You can assume the data is all there and it is correct. You can use my cd file or create one of your own, but make sure it works with my file.

Option 2: Displays all 17 records with the following column headings: Artist Title Year Released

NOTE – Violating any of the following is grounds for getting an F on your lab:

You will NEVER use break, exit, return, pass, continue or anything to leave a loop (or iteration), function, or other construct prematurely, unless it is part of the structure as in a case statement.

You will NEVER have a function call itself, unless it is intentional recursion.

You will NEVER use global variables. However, you may use global constants if it is appropriate and they are used properly.

You will have only one return statement in a function.

cd.txt

Testament
The Gathering
1999
Five Finger Death Punch
American Capitalist
2011
Trivium
In Waves
2011
Megadeth
Rust in Peace
1990
In Flames
Sounds of a Playground Fading
2011
Marilyn Manson
Holy Wood
2000
Rob Zombie
Hellbilly Deluxe
1998
The Misfits
American Psycho
1997
Metallica
Ride the Lightning
1984
Pantera
Cowboys From Hell
1990
In Flames
Clayman
2000
Testament
Dark Roots of Earth
2012
Anthrax
Worship Music
2011
Savatage
The Wake of Magellan
1997
Trivium
Shogun
2008
The Cult
Sonic Temple
1989
Testament
Demonic
1997
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ program given below......

#include <iostream>
#include <string.h>
#include <fstream>
#include <stdlib.h>
using namespace std;

// Structure for record.....
struct record
{
char artist[50];
char title[50];
char year[50];
};

int main()
{
// Records array.....
struct record rc[18];

// Input file pointer
ifstream ptr;

ptr.open("cd.txt");

// Check for errors.....
if(!ptr)
{
cout<<"\nFile opening error\n";
exit(1);
}

// Option 1: Read records from file....
for(int i=1;i<18;i++)
{
ptr.clear();
ptr.getline(rc[i].artist, 50);
ptr.clear();
ptr.getline(rc[i].title, 50);
ptr.clear();
ptr.getline(rc[i].year, 50);
}

// Option 2: Display records............
cout<<"Artist.........Title......Year!\n\n";
for(int i=1;i<18;i++)
{
cout<<rc[i].artist<<"\t"<<rc[i].title<<"\t"<<rc[i].year<<endl;
}

ptr.close();

return 0;
}

Terminal 1, E ·M) (100%) w) 11:16PM * Open Save C.cpp cd.txt #include iostream> 2#include <string . h> #include cfstream» 4 #

Add a comment
Know the answer?
Add Answer to:
c++ Each menu choice will call a different function. If you did not put the Math...
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
  • Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you....

    Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you. Phase 1 You must design 3 algorithms, and provide both a flow chart and pseudo code for the algorithms.    Algorithm descriptions: Given an integer parameter named current_number and two constant global variables: const int MIN_NUMBER = 1; const int MAX_NUMBER = 8; Create an algorithm named forward, that will advance ONE value through a sequence of numbers 1, 2, 3 ... MAX_NUMBER. In...

  • ***********************PLEASE DO NOT COPY AND PASTE OLD SOLUTIONS*************************** C++ Assignment Write a menu driven program with...

    ***********************PLEASE DO NOT COPY AND PASTE OLD SOLUTIONS*************************** C++ Assignment Write a menu driven program with the following options to call a recursive function, which raise x to the power n must work for negative n as well as positive n. ( x − n = 1/ x n ) ask a user for the values of x and n to call a recursive function to add the first n terms of the series 1+1/2+1/3...1/n function output sample: 1+1/2+1/3+1/4+= 2.0833...

  • please use C++ write a program to read a textfile containing a list of books. each...

    please use C++ write a program to read a textfile containing a list of books. each line in the file has tile, ... Question: Write a program to read a textfile containing a list of books. each line in the file has tile, ..... write a program to read a textfile containing a list of books. each line in the file has tile, ... Question: Write a program to read a textfile containing a list of books. Each line in...

  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • I need help with this assignment in C++, please! *** The instructions and programming style detai...

    I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this assignment! Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...

  • C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include ...

    C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include <stdio.h> int main() { int fries; // A flag denoting whether they want fries or not. char bacon; // A character for storing their bacon preference. double cost = 0.0; // The total cost of their meal, initialized to start at 0.0 int choice; // A variable new to version 2, choice is an int that will store the // user's menu choice. It will also serve as our loop control...

  • Assignment You will be developing a speeding ticket fee calculator. This program will ask for a t...

    Assignment You will be developing a speeding ticket fee calculator. This program will ask for a ticket file, which is produced by a central police database, and your program will output to a file or to the console depending on the command line arguments. Furthermore, your program will restrict the output to the starting and ending dates given by the user. The ticket fee is calculated using four multipliers, depending on the type of road the ticket was issued: Interstate...

  • SOLVE USING C!!! Project objective: Conditional statements, loops, reading from file, user defined functions. **Submit source...

    SOLVE USING C!!! Project objective: Conditional statements, loops, reading from file, user defined functions. **Submit source code (LargeProg1.c) through Canvas One source code file(unformatted text) will be submitted Here is INCOMPLETE code to get started: LargeProg1.c The file name must match the assignment The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas The code must be submitted on time in order to receive credit (11:59PM on the due date) Late submissions will...

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • Program is in C++, program is called airplane reservation. It is suppose to display a screen...

    Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...

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
ADVERTISEMENT