[solved] – Question 77719
Write a recursive function
bool is_palindrome(string str)
that returns true if str is a palindrome, that is, a word that is the same when reversed. Examples of palindrome are “deed”, “rotor”, or “aibohphobia”. Hint: A word is a palindrome if the first and last letters match and the remainder is also a palindrome.
Expert Answer
[solved] – Question 77720
Write a program that, given a month and year, prints a calendar, such as
June 2016
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
To find out the weekday of the first day of the month, call this function:
/**
Computes the weekday of a given date.
@param year the year
@param month the month (1 = January … 12 = December)
@param day the day of the month
@return the weekday (0 = Sunday … 6 = Saturday)
*/
int day_of_week(int year, int month, int day)
{
int y = year;
int m = month – 1;
if (month < 3) { y–; m = m + 4; }
return (y + y / 4 – y / 100 + y / 400
+ 3 * m + 4 – (m – m / 8) / 2 + day) % 7;
}
Make a helper function to print the header and a helper function to print each row.
Expert Answer
[solved] – Question 77721
A supermarket wants to reward its best customer of each day, showing the customer’s name on a screen in the supermarket. For that purpose, the customer’s purchase amount is stored in a vector<double> and the customer’s name is stored in a corresponding vector<string>.
Implement a function
string name_of_best_customer(vector<double> sales,
vector<string> customers)
that returns the name of the customer with the largest sale.
Expert Answer
[solved] – Question 77723
You should use a radio button to request the user enter either EVEN or ODD and a text box for
a number between 1 and 20. You should check to make sure both the values entered comply
with the previous sentence and if not, you should change them to EVEN and 5.
If the user enters EVEN you should output all the numbers between 1 and what they entered
that are EVEN. Do not output the number 1. You should output the number they entered if it is
EVEN.
If the user enters ODD you should output all the numbers between 1 and what they entered
that are ODD. Do not output the number 1. You should output the number they entered if it is
ODD.
If the user enters 1 for their number between 1 and 20 you should output “There are no even
or odd numbers between 1 and 1. Changing your input to 5.”
Expert Answer
[solved] – Question 77724
Suppose the array primes, defined as
double primes[] = { 2, 3, 5, 7, 11, 13 };
starts at memory location 20300. What are the values of
a.primes
b.*primes
c.primes + 4
d.*(primes + 4)
e.primes[4]
f.&primes[4]
Expert Answer
[solved] – Question 77725
Write a function that returns a pointer to the last occurrence of the character c in the string s, or nullptr if there is no match.
char* find_last(char s[], char c)
Expert Answer
[solved] – Question 77726
Define a structure Triangle that contains three Point members. Write a function that computes the perimeter of a Triangle. Write a program that reads the coordinates of the points, calls your function, and displays the result.
Expert Answer
[solved] – Question 77727
Define a structure Student with a name and a vector<Course*> of courses. Define a structure Course with a name and a vector<Student*> of enrolled students. Then define these functions:
•void print_student(Student* s) that prints the name of a student and the names of all courses that the student takes.
•void print_course(Course* c) that prints the name of a course and the names of all students in that course.
•void enroll(Student* s, Course* c) that enrolls the given student in the given course, updating both vectors.
In your main function, define several students and courses, and enroll students in the courses. Then call print_student for all students and print_course for all courses.
Expert Answer
[solved] – Question 77728
A microwave control panel has four buttons: one for increasing the time by 30 seconds, one for switching between power levels 1 and 2, a reset button, and a start button. Implement a class that simulates the microwave, with a member function for each button. The member function for the start button should print a message “Cooking for … seconds at level …”.
Expert Answer
[solved] – Question 77729
Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply an appropriate constructor and functions get_name(), add_quiz(int score), get_total_score(), and get_average_score(). To compute the latter, you also need to store the number of quizzes that the student took.
Expert Answer

