First week of the current trimester and we've taken a huge leap from writing little code snippets of loops and switches to writing an entire program, and expecting it to work!
I, nor anyone else in my class have heard of structs which is our first assignment. I've been pounding away for several days now and it won't compile beyond my struct declaration. Anyone who knows a bit about C++ I would enjoy you pointing out all of the syntax and logical errors in the first dozen lines of what is over 100 lines of code so far on this program. Here is the guideline:
CIS 247: Programming Assignment #1
Worth 5 Points Assigned: Week 1 Due: Week 3
You have contracted with a media company that deals with CDs, books, movies and video games and will be helping them manage inventory for one of the types of media.
Create a program that will internally store at least eight media items. Use a global (declared above main() ) structure called book, cd, movie or videoGame. Include at least five member variables (select the appropriate data types) to represent different attributes of a media (some examples: pages, cost, runningTime, format, hardcover, genre, …, etc.).
● One of them has to be price, because I will have you calculate tax (rate 8.5%) and total cost.
● One has to be a char array (C-String) and
● One has to be a char that is an abbreviation (such as r for Red). You select anything for the other two.
In main(), create 6 global month structure variables to represent the six different media items. For example, a structure for a shirt inventory might be:
struct shirt {
char size; // S, M, L, X;
char brand[15]; // uses C-style strings instead of string objects
bool shortSleeve;
char color; // for the required switch statement (r=Red, u=Blue, g=Green, w=White, b=Black, y=Yellow)
double price;
};
Note: The above code is an example, not to be used verbatim. Please choose your own set of variable names and data. You may use similar names. The structure can have the variables in any order.
You can load the data into the structures at the time of declaration, or read from a file.
struct shirt concert={'M', “Hanes”, true, ‘b’, 12.5}; // this would be shirt number 1
struct shirt work={'L', “Sears”, false, ‘u’, 21.95}; // this would be shirt number 2
…
… // shirt number 7
… // shirt number 8
Note: Select only one media type, come up with your own naming for the variables and use your own (unique) data.
Write a program that will generate a report showing all of the six media items (I'm using shirts instead here). Requirements:
● Create a text menu using a switch() block, to ask for media number, or 0 for all of them, or 99 to exit. All other input will result in an error message.
● Write one function that accepts media number as an int (1-8) and prints the appropriate media package information (see Sample Output), by passing the appropriate media to the function as a parameter. It will use the switch() statement to display the appropriate color (or whatever you want to use as a coded item),
I will be using the following key for color of shirt: (r=Red, u=Blue, g=Green, w=White, b=Black, y=Yellow)
Sample Output - Show output for at least 4 of the 6 items in your inventory
Shirt Menu
Please Enter 1-8 to list the shirts
Please Enter 0 to list all shirts
Please Enter 99 to end the program
Selection: 2
You have chosen to display information on the Sears shirt:
Size: L
Long Sleeve
Color: Blue
Price: $21.95
Tax: $ 1.87
Total Cost: $23.82
Note that the output will depend upon the type of media (not shirt) and variables that you select.
Now, I've given a great deal of effort into the code you are going to be looking at so keep in mind 6 months ago I had never stroked one key of code.
I'm not sure I'm posting this in the right area either, if not someone please direct me to the C++ posting threads please.
//Assignment One CIS247 Joseph Matzke
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
struct movie
{
string rating; //G,PG,PG13,R17,X ,XXX
char title; //Oceans 13, Oceans 12, Oceans 11, Braveheart, Harry Potter, Caligula
bool releaseDate; //Still in theatre-released
char language;//English, Spanish, Japanese, Chinese, German, Swaheely
double cost [2];
double tax;
};
void playMovie (struct movie); //it will not compile beyond here
int main(void)
{
int choice = 0;
//movie anyMovie; //declaration-creates object?
struct movie1={"R17", "Oceans 13", true, 'E', 19.99}; //movie number 1
movie movie2={"R17", "Oceans 12", false, 'E', 9.99};
movie movie3={"R17", "Oceans 11", false, 'E', 9.99);
movie movie4={"R17", "Braveheart ", false, 'E', 9.99};
movie movie5={"PG", "Harry Potter", false, 'E', 9.99};
movie movie6={"XXX", "Caligula", false, 'S', 1.99};
system ("pause");
return 0;
}
do
{
cout << "Please enter 0 to list all movies" << endl; //makes sense to display the menu for choice
cout << "Pleae enter 99 to end the program" << endl; //either display the menu or stop the program
cout << "Selection: ";
There is a lot more code to this, my switch module, my array, and so on but they do me no good if I can't compile beyond where I've noted.
I've changed from --void main (void) to--int main()--to int main (void)-- and regardless of what I do, actually my original code did not have a return in the main but the compiler message seemed to want me to return an int. Can anyone spot the problem? Thanks
I, nor anyone else in my class have heard of structs which is our first assignment. I've been pounding away for several days now and it won't compile beyond my struct declaration. Anyone who knows a bit about C++ I would enjoy you pointing out all of the syntax and logical errors in the first dozen lines of what is over 100 lines of code so far on this program. Here is the guideline:
CIS 247: Programming Assignment #1
Worth 5 Points Assigned: Week 1 Due: Week 3
You have contracted with a media company that deals with CDs, books, movies and video games and will be helping them manage inventory for one of the types of media.
Create a program that will internally store at least eight media items. Use a global (declared above main() ) structure called book, cd, movie or videoGame. Include at least five member variables (select the appropriate data types) to represent different attributes of a media (some examples: pages, cost, runningTime, format, hardcover, genre, …, etc.).
● One of them has to be price, because I will have you calculate tax (rate 8.5%) and total cost.
● One has to be a char array (C-String) and
● One has to be a char that is an abbreviation (such as r for Red). You select anything for the other two.
In main(), create 6 global month structure variables to represent the six different media items. For example, a structure for a shirt inventory might be:
struct shirt {
char size; // S, M, L, X;
char brand[15]; // uses C-style strings instead of string objects
bool shortSleeve;
char color; // for the required switch statement (r=Red, u=Blue, g=Green, w=White, b=Black, y=Yellow)
double price;
};
Note: The above code is an example, not to be used verbatim. Please choose your own set of variable names and data. You may use similar names. The structure can have the variables in any order.
You can load the data into the structures at the time of declaration, or read from a file.
struct shirt concert={'M', “Hanes”, true, ‘b’, 12.5}; // this would be shirt number 1
struct shirt work={'L', “Sears”, false, ‘u’, 21.95}; // this would be shirt number 2
…
… // shirt number 7
… // shirt number 8
Note: Select only one media type, come up with your own naming for the variables and use your own (unique) data.
Write a program that will generate a report showing all of the six media items (I'm using shirts instead here). Requirements:
● Create a text menu using a switch() block, to ask for media number, or 0 for all of them, or 99 to exit. All other input will result in an error message.
● Write one function that accepts media number as an int (1-8) and prints the appropriate media package information (see Sample Output), by passing the appropriate media to the function as a parameter. It will use the switch() statement to display the appropriate color (or whatever you want to use as a coded item),
I will be using the following key for color of shirt: (r=Red, u=Blue, g=Green, w=White, b=Black, y=Yellow)
Sample Output - Show output for at least 4 of the 6 items in your inventory
Shirt Menu
Please Enter 1-8 to list the shirts
Please Enter 0 to list all shirts
Please Enter 99 to end the program
Selection: 2
You have chosen to display information on the Sears shirt:
Size: L
Long Sleeve
Color: Blue
Price: $21.95
Tax: $ 1.87
Total Cost: $23.82
Note that the output will depend upon the type of media (not shirt) and variables that you select.
Now, I've given a great deal of effort into the code you are going to be looking at so keep in mind 6 months ago I had never stroked one key of code.
I'm not sure I'm posting this in the right area either, if not someone please direct me to the C++ posting threads please.
//Assignment One CIS247 Joseph Matzke
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
struct movie
{
string rating; //G,PG,PG13,R17,X ,XXX
char title; //Oceans 13, Oceans 12, Oceans 11, Braveheart, Harry Potter, Caligula
bool releaseDate; //Still in theatre-released
char language;//English, Spanish, Japanese, Chinese, German, Swaheely
double cost [2];
double tax;
};
void playMovie (struct movie); //it will not compile beyond here
int main(void)
{
int choice = 0;
//movie anyMovie; //declaration-creates object?
struct movie1={"R17", "Oceans 13", true, 'E', 19.99}; //movie number 1
movie movie2={"R17", "Oceans 12", false, 'E', 9.99};
movie movie3={"R17", "Oceans 11", false, 'E', 9.99);
movie movie4={"R17", "Braveheart ", false, 'E', 9.99};
movie movie5={"PG", "Harry Potter", false, 'E', 9.99};
movie movie6={"XXX", "Caligula", false, 'S', 1.99};
system ("pause");
return 0;
}
do
{
cout << "Please enter 0 to list all movies" << endl; //makes sense to display the menu for choice
cout << "Pleae enter 99 to end the program" << endl; //either display the menu or stop the program
cout << "Selection: ";
There is a lot more code to this, my switch module, my array, and so on but they do me no good if I can't compile beyond where I've noted.
I've changed from --void main (void) to--int main()--to int main (void)-- and regardless of what I do, actually my original code did not have a return in the main but the compiler message seemed to want me to return an int. Can anyone spot the problem? Thanks
Comment