Você está na página 1de 6

1.

Julio Cesar Chavez Mark VII is an interplanetary space boxer, who currently holds the
championship belts for various weight categories on many different planets within our solar
system. However, it is often difficult for him to recall what his "target weight" needs to be on
earth in order to make the weight class on other planets. Write a program to help him keep track
of this.

It should ask him what his earth weight is, and to enter a number for the planet he wants to fight
on. It should then compute his weight on the destination planet based on the table below:

# Planet Relative gravity


1 Venus 0.78
2 Mars 0.39
3 Jupiter 2.65
4 Saturn 1.17
5 Uranus 1.05
6 Neptune 1.23

So, for example, if Julio weighs 128 lbs. on earth, then he would weigh just under 50 lbs. on
Mars, since Mars' gravity is 0.39 times earth's gravity. (128 * 0.39 is 49.92)

Please enter your current earth weight: 128

I have information for the following planets:


1. Venus 2. Mars 3. Jupiter
4. Saturn 5. Uranus 6. Neptune

Which planet are you visiting? 2

Your weight would be 49.92 pounds on that planet.

2. Write a program that pulls up a menu with 4 options. It should look something like...

Ye Olde Keychain Shoppe

1. Add Keychains to Order


2. Remove Keychains from Order
3. View Current Order
4. Checkout

Please enter your choice: 1

ADD KEYCHAINS

1. Add Keychains to Order


2. Remove Keychains from Order
3. View Current Order
4. Checkout
Please enter your choice: 3

VIEW ORDER

1. Add Keychains to Order


2. Remove Keychains from Order
3. View Current Order
4. Checkout

Please enter your choice: 4

CHECKOUT

 You will need to create functions for each of the 4 menu options. Entering the number
will call the correct function.
 This assignment does not require you to complete ANY of the functionality except for the
working menu system. There is no need for you to program the ability to add keychains,
remove keychains, view orders or checkout.
 The functions should be named add_keychains(), remove_keychains(), view_order() and
checkout().
 Each function should print a message that it has been called.
 The user should be able to keep putting in choices until the checkout() function is called.
When checkout() is finished, the program should end.

3. Weekday Calculator

Using the functions you wrote in previous assignments and the leap year function provided, write
a function to determine the day of the week a person was born given his or her birthday. The
following steps should be used to find the day of the week corresponding to any date from 1901
through the present.

In the following explanation, the following terms will be helpful. Assuming I type in my
birthday as "6 10 1981":

The month is 6.
The day of the month is 10.
The year is 1981.

1. Find the number of years since 1900, and put it into a variable called yy. Simply subtract
1900 from the year to get this.
2. Divide the number of years since 1900 by 4. Put the quotient in a variable called total.
For example, if the person was born in 1983, divide 83 by 4 and store 20 in total.
3. Also add the number of years since 1900 to total.
4. Add the day of the month to total.
5. Using the function month_offset() you wrote, find the "month offset" and add it to
total.
6. If the year is a leap year and if the month you are working with is either January or
February, then subtract 1 from the total. You can use the function is_leap() provided
to determine if the year is a leap year.
7. Find the remainder when total is divided by 7. Pass this remainder to the function
weekday_name() you wrote to determine the day of the week the person was born.
8. Finally, build up a single String value containing the whole date (day of week, month,
day, year). You'll need to use the function month_name() you wrote to show the month
name rather than its number.
9. Return that String value.

Welcome to Mr. Mitchell's fantastic birth-o-meter!

All you have to do is enter your birthday, and it will tell you
the day of the week on which you were born.

Some automatic tests....


12 10 2003 => Wednesday, December 10, 2003
2 13 1976 => Friday, February 13, 1976
2 13 1977 => Sunday, February 13, 1977
7 2 1974 => Tuesday, July 2, 1974
1 15 2003 => Wednesday, January 15, 2003
10 13 2000 => Friday, October 13, 2000

Now it's your turn! What's your birthday?


Birthday (mm dd yyyy): 11 11 2010

You were born on Thursday, November 11, 2010!


4. You are in-charge of the cake for your niece's birthday and have decided the cake will have
one candle for each year of her total age. When she blows out the candles, she’ll only be able to
blow out the tallest ones. Your task is to find out how many candles she can successfully blow
out.

For example, if your niece is turning years old, and the cake will have candles of height , , , , she
will be able to blow out candles successfully, since the tallest candle is of height and there are
such candles.

Function Description

Complete the function birthdayCakeCandles in the editor below. It must return an integer
representing the number of candles she can blow out.

birthdayCakeCandles has the following parameter(s):

 k: the integer threshold of students on time for class to continue


 a: an array of integers representing student arrival times

Input Format

The first line contains a single integer, , denoting the number of candles on the cake.
The second line contains space-separated integers, where each integer describes the height of
candle .

Output Format

 Print the number of candles that can be blown out on a new line.

Sample Input 0

 4
 3 2 1 3

Sample Output 0

 2

Explanation 0

 We have one candle of height , one candle of height , and two candles of height . Your
niece only blows out the tallest candles, meaning the candles where . Because there are
such candles, we print on a new line.
// Complete the birthdayCakeCandles function below.

int birthdayCakeCandles(vector<int> ar)

5. Given a time in -hour AM/PM format, convert it to military (24-hour) time.

Note: Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is
12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock.

Function Description

Complete the timeConversion function in the editor below. It should return a new string
representing the input time in 24 hour format.

timeConversion has the following parameter(s):

 s: a string representing time in hour format

Input Format

A single string containing a time in -hour clock format (i.e.: or ), where and .

Constraints

 All input times are valid

Output Format

Convert and print the given time in -hour format, where .

Sample Input 0

07:05:45PM

Sample Output 0

19:05:45
string timeConversion(string s)

/*

* Write your code here.

*/

Você também pode gostar