Task 9.1. Re-Write The Code After Fixing The Errors.: (Need To Submit Task 9.2 and Task 9.3 As A Part of Assignment 3)
Task 9.1. Re-Write The Code After Fixing The Errors.: (Need To Submit Task 9.2 and Task 9.3 As A Part of Assignment 3)
Lab 9: (Need to submit Task 9.2 and Task 9.3 as a part of assignment 3)
#include<iostream>
using namespace std;
struct emp
{
char *surname;
int age;
float salary;
}
int main()
{
struct emp ricky;
struct emp *aPtr;
ricky.surname = "Peter";
ricky.age = 35;
ricky.salary = 2000.53;
aPtr = &ricky;
Task 9.2 Use the following structure for this problem. (Need to submit this task as a part of
assignment 3)
struct company_detail
{
string company_id;
string company_name;
};
struct Emp
{
string emp_name;
string emp_id;
double salary;
struct company_detail cmp_detail;
};
Enum - Introduction
An enumeration is a user-defined data type that consists of set of integers. To define an
enumeration, keyword enum is used.
Eg:
enum months {
JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
}; // end enum months
creates a new type, enum months, in which the identifiers are set to the integers 0 to 11,
respectively.
enum months {
JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
}; // this number the months 1 to 12.
#include <iostream>
#include <cstdlib>
using namespace std;
enum week { sunday, monday, tuesday, wednesday, thursday, friday, saturday };
void lecture_unit(week day)
{
switch(day)
{
case monday:
cout<<"SWE20004\n";
break;
case tuesday:
cout<<"COS10009\n";
break;
/*
.
.
.
*/
case sunday:
©Copyright: 2018 Swinburne University of Technology CRICOS: 0011D TOID: 3059
Week 9 Lab Page 2 of 5
SWE200024 – Technical Software Development
cout<<"Holiday\n";
break;
}
}
int main()
{
int day;
cout<<"What is the day today? 0 - Sunday, 1 - Monday, 2 -Tuesday etc "<<endl;
cin>>day;
week today = static_cast<week>(day);
lecture_unit(today);
return 0;
}
Your program should read in several album names, each album has up to 5 tracks as
well as a genre.
First declare genre for the album as an enumeration with at least three entries. Then
declare an album structure that has five elements to hold the album name, genre, number
of tracks, name of those tracks and track location.
You can use the template given below, but highly recommended to use your own variable
names and enumeration list.
Declare a vector (user determines the number of albums at the runtime) of type album
to create database for album.
Option 1: call a function add_album – it allows the user to enter the album details.
Option 2: call a function named print_all_album to print out the album details.
When the user selects a track to play your program must call an external program
to play the track.
Option 4: Quit
Screen shot continue in the next page, these screen shots are taken from a single run.