Hello,
I've read this textbook like a-kezillion times, and i still can't understand why we use the '&' in void function.
can somebody please explain.
thanks.
ps : please don't give that lmgtfy.com thingy. it's annoying.
Hello,
I've read this textbook like a-kezillion times, and i still can't understand why we use the '&' in void function.
can somebody please explain.
thanks.
ps : please don't give that lmgtfy.com thingy. it's annoying.
On line 45 you're cout-ing time, not cin-ing it.
thanks!!!
in case you guys wanna know what the question for the code is;
Your swim shcool has two swimming instructors, Jeff and Anna. Their current schedules are shown below. An "X" denotes a one-hour time slot that is occupied with a lesson.
Jeff Monday Tuesday Wednesday Thursday
11-12 X X
12-1 X X X
1-2 X X
2-3 X X X
Anna Monday Tuesday Wednesday Thursday
11-12 X X X
12-1 X X
1-2 X X
2-3 X X X
Write a program with arrays capable of storing the schedules. Create a main menu that allows the user to mark a time slot as busy or free for either instructor. Also, add an option to output the schedules to the screen. Next, add an option to output all time slots available for individual lessons (slots when at least one instructor is free). Finally add an option to output all time slots available for group lessons (when both instructures are free)
Your program should employ the following:
·
as indicated in the problem description: 2 two-dimensional arrays, one for Jeff’s
schedule, and one for Anna’s
·
a main menu that provides options to the user
·
a function that prints the schedule
·
a function that prompts the user to select an
instructor, day, and slot
·
a function that prompts the user, then …
ok, i have a bigger problem. when i run the program (something like this);
"Which swimming instructor would you like to choose? Enter j for Jeff, Enter a for Anna
j
Please enter the first letter of the day of the week you would like to schedule.
M for Monday, T for Tuesday, W for Wednesday, R for Thursday.
m
Please enter a time, 11, 12, 1, or 2.
0You entered an invalid time."
the problem is, i only put j, and m myself. i didn't put 0 myself. what's the problem?
here's the entire code
#include<iostream>
#include<iomanip>
using namespace std;
void scedulejeff (char [][4]);
void sceduleanna (char [][4]);
void Print2DArray(char [][4]);
int X;
int main()
{
char jeffarray [4][4];
char annaarray [4][4];
char instructor;
cout << "Which swimming instructor would you like to choose? Enter j for Jeff, Enter a for Anna\n";
cin >> instructor;
if ((instructor == 'j') || (instructor == 'J'))
{
scedulejeff (jeffarray);
}
else if ((instructor == 'a') || (instructor == 'A'))
{
scedulejeff (annaarray);
}
else
{
cout << "You've entered an invalid alphabet. Please choose between j for Jeff, or a for Anna.\n";
}
}
void scedulejeff (char a1 [][4])
{
char day;
int time;
cout << "Please enter the first letter of the day of the week you would like to schedule.\n"
"M for Monday, T for Tuesday, W for Wednesday, R for Thursday.\n";
cin >> day;
cout << "Please …
declare all the X is switch statement. why?
ok, i think i got everything right. would you mind double check it i've done something wrong... :)
#include<iostream>
#include<iomanip>
using namespace std;
void scedulejeff (char [][4]);
void sceduleanna (char [][4]);
void Print2DArray(char [][4]);
int X;
int main()
{
char jeffarray [4][4];
char annaarray [4][4];
char instructor;
cout << "What instructor would you like to scedule a time slot for, for Jeff enter j, for Anna enter a?\n";
cin >> instructor;
if ((instructor == 'j') || (instructor == 'J'))
{
scedulejeff (jeffarray);
}
else if ((instructor == 'a') || (instructor == 'A'))
{
sceduleanna (annaarray);
}
else
{
cout << "you entered an invalid charater please enter a 'j' for Jeff or 'a' for Anna.\n";
}
}
void scedulejeff (char a1 [][4])
{
char day;
int time;
cout << "Please enter the first letter of the day of the week you would like to scedule.\n"
"enter M for Monday, T for Tuesday, W for Wednesday, or R for Thursday.\n";
cin >> day;
cout << "Please enter a time, 11, 12, 1, or 2.\n";
cout << time;
switch (day)
{
case 'M':
case 'm':
if (time == 11)
{
a1 [0][0] = X;
}
else if (time == 12)
{
a1 [1][0] = X;
}
else if (time == 1)
{
a1 [2][0] = X;
}
else if (time == 2)
{
a1 [3][0] = X;
}
else
{
cout << "You entered an invalid time.\n";
return;
}
break;
case 'T':
case 't':
if (time == 11)
{
a1 [0][1] …
i'm using xcode... it says there's something wrong with row 11.
OK, i can't figure out what kind of mistake I've done. Can somebody help me please.
#include<iostream>
#include<iomanip>
using namespace std;
void scedulejeff (char [][4]);
void sceduleanna (char [][4]);
void Print2DArray(char [][4]);
int main()
{
char jeffarray [4][4];
char annaarray [4][4];
char instructor;
cout << "What instructor would you like to scedule a time slot for, for Jeff enter j, for Anna enter a?\n";
cin >> instructor;
if ((instructor==j) || (instructor==J))
{
scedulejeff (jeffarray);
}
if else ((instructor==a) || (instructor==A))
{
scedulejeff (annaarray);
}
else
{
cout << "you entered an invalid charater please enter a 'j' for Jeff or 'a' for Anna.\n";
}
}
Declare a 2-D array that will contain up to 20 rows
and 15 columns. The template for this lab that has been
posted on ANGEL contains code to prompt the user to enter the number of
rows
and columns he/she would like to use, confirms the user’s entry is
valid, and
contains a function to print the array.
You are to add a function that will accept the 2D array and the
rows and
columns specified by the user then fill the array so that each number in
the
array is (2 * the row index) plus (3 * the column index).
For example a 3 by 4 matrix would look like
0 4 5 9
1 5 8 11
4 7 10 13
Before you try to write any
code, clearly
define the purpose of your function, the necessary input for your
function and
the processing that your function will employ as comments before your
function. (Do
NOT ask for help with code unless these comments are written, you may
ask for
help in answering the questions.)
Once
your function has been written add the function calls and function
prototypes for
your function and for the function to print the array.
below is what I tried so far
and I need help on part that …
Hello,
Currently, i was assigned to create an array, which i have no idea what array is.
The problem is this....
2.Write a function to read in numbers and put them into the array. The function should continue to read in numbers until either: the user types a negative number, or 100 numbers (hint: MAXSIZE) have been read. The function should also return the number of elements in the array. Write comments before the function that describe what the function does, what it needs passed to it, what it sends back to the function call, and how it accomplishes its task.
3.Then write a second function that will accept an array and print out the contents of the array. This function should accept an array and the number of elements that are to be printed. Before writing the code for this function, write the comments.
#include <iostream>
using namespace std;
int Function1(double []);
void PrintArray(const double [], int);
const int MAXSIZE =100;
int main()
{
double array1[100];
int count;
count = Function1(array1);
cout<<"There were "<<count<<" numbers entered into the array."<<endl;
//function call to for the array
return 0;
}
//Write the function here to read in numbers into the array.
//add comments describing what this function does,
int Function1(double myarray[])
{
}
//Write the new function here along with comments
//add comments describing what this function does, what is passed to it, what it sends back, etc.
void PrintArray(const double a1[], int size)
{
}