1, Branches: Leap Year A year in the modern Gregorian

1,

Branches: Leap Year

A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:

1) The year must be divisible by 4

2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400

Some example leap years are 1600, 1712, and 2016.

Write a program that takes in a year and determines whether that year is a leap year.

Ex: If the input is:

1712

the output is:

1712 is a leap year.

Ex: If the input is:

1913

the output is:

1913 is not a leap year.

2, Branches: Remove gray from RGB

Summary: Given integer values for red, green, and blue, subtract the gray from each value.

Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color’s value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray).

Given values for red, green, and blue, remove the gray part.

Ex: If the input is:

130 50 130

the output is:

80 0 80

Hint: Find the smallest value, and then subtract it from all three values, thus removing the gray

3,  Branches: Largest number

Write a program that reads three integers as inputs, and outputs the largest of the three values.

Ex: If the input is:

7 15 3

the output is:

15

3,Variables/Assignments: Divide by x

Write a program using integers userNum and x as input, and output userNum divided by x four times.

Ex: If the input is:

2000 2

the output is:

1000 500 250 125

Note: In Coral, integer division discards fractions. Ex: 6 / 4 is 1 (the 0.5 is discarded).

4,  Variables/Assignments: Driving costs

Driving is expensive. Write a program with a car’s miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles.

Output the gas cost (gasCost) with two digits after the decimal point, which can be achieved as follows:
Put gasCost to output with 2 decimal places

Ex: If the input is:

20.0 3.1599

the output is:

1.58 7.90 63.20

Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a + b)/3.0 is the same as a/3.0 + b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. First use the dollars/gallon and miles/gallon values to calculate the dollars/mile. Then use the dollars/mile value to determine the cost per 10, 50, and 400 miles.

Note: Real per-mile cost would also include maintenance and depreciation.

5,  Variables/Assignments: Using math functions

Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolute value of x, and the square root of (x * y to the power of z).

Output all results with five digits after the decimal point, which can be achieved as follows:
Put result to output with 5 decimal places

Ex: If the input is:

5.0 2.5 1.5

the output is:

55.90170 579.32402 5.00000 6.64787

Hint: Coral has built-in math functions (discussed elsewhere) that may be used.

6,  Variables/Assignments: Using math functions

Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolute value of x, and the square root of (x * y to the power of z).

Output all results with five digits after the decimal point, which can be achieved as follows:
Put result to output with 5 decimal places

Ex: If the input is:

5.0 2.5 1.5

the output is:

55.90170 579.32402 5.00000 6.64787

Hint: Coral has built-in math functions (discussed elsewhere) that may be used.

7,  Arrays: Middle item

Given a sorted list of integers, output the middle integer. A negative number indicates the end of the input (the negative number is not a part of the sorted list). Assume the number of integers is always odd.

Ex: If the input is:

2 3 4 8 11 -1 

the output is:

4

The maximum number of inputs for any test case should not exceed 9 positive values. If exceeded, output “Too many inputs”.

Hint: Use an array of size 9. First, read the data into an array. Then, based on the number of items, find the middle item.

8,Arrays: Output values below an amount

Write a program that first reads a list of 5 integers from input. Then, read another value from the input, and output all integers less than or equal to that last value.

Ex: If the input is:

50 60 140 200 75 100

the output is:

50 60 75

For coding simplicity, follow every output value by a space, including the last one. Then, output a newline.

Such functionality is common on sites like Amazon, where a user can filter results.

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

1. Why she made the decision to breastfeed or formula

1.  Why she made the decision to breastfeed or formula feed?  2.  What challenges [if any] has she faced in feeding her baby? 3.  Has she received any criticism or unwanted advice from people about the feeding method she chose?  4.  What are her feelings about breastfeeding or formula feeding?

Answer the following questions and support your answers with facts

  Answer the following questions and support your answers with facts from the scenario and legal analysis, utilizing the cases provided or additional cases obtained through your own research. Be sure to state the case names and citations of all cases you use in support of your arguments in your document.

Talk about the “The First Metaphysics and Current Metaphysical Concerns”.

Talk about the  “The First Metaphysics and Current Metaphysical Concerns”.  How the Pre-Socratic philosophers attempted to explain the nature of reality and the origin of life through materialism and spiritualism (idealism). Compare the Sophists’ metaphysical views with Socrates’ view concerning truths, morals, and view on the nature of being (human

Summary: Your paper should be at least three (3) pages,

 Summary: Your paper should be at least three (3) pages, double-spaced, in Arial or Times New Roman font (12 point), contain at least three (3) references, and cover the following topics: A brief description of how and when the disease was first identified (i.e., historical perspective). (20 points) What specific

Q1 :Discuss the standard or test that the Supreme Court

 Q1 :Discuss the standard or test that the Supreme Court created to evaluate the constitutionality of uses of force in correctional institutions. That requires discussing  the Supreme Court’s decisions in the cases Albers v. Whitley and Hudson v. McMillian. How would a court apply those two decisions and the standards

Reply to: Researchers within the field of psychology are interested

Reply to:   Researchers within the field of psychology are interested in various higher order cognitive functions exhibited within human behavior. However, one area that is highly researched is that of language, or the way in which human beings communicate with one another. This communication can take place and be

You have had a relationship with archetypes since a young

  You have had a relationship with archetypes since a young age—Carl Jung might argue this is true since your conception.  In fact, many children’s cartoons use archetypes as part of their humor (think of Tweedy Bird and Sylvester, Tom and Jerry, or The Simpsons).  Throughout this unit, you have identified common archetypes across ancient and

Select a MACRONUTRIENT and an area of concern (disease state,

You will be required to research a nutrition topic of your choice based on the subjects we are discussing. You must find a research article on your topic, from an accredited journal (i.e. The Journal of Clinical Nutrition, The Journal of the Academy of Nutrition and Dietetics (JADA, JAMA. The

As a scholar-practitioner, it will be important for you to

   As a scholar-practitioner, it will be important for you to develop your knowledge and skillset in hypothesis testing. As evident in the scenario provided, hypothesis testing establishes a process to determine the probability of observing similar scores noted in the sample under the null hypothesis. For this week, you

DISCUSSION APA 7th format 300-350 words—ok if a little shorter Please do not accept if you are not familiar with nursing and informatics. =this must make sense Post a description of experiences or o Nursing Assignment Help

DISCUSSION APA 7th format 300-350 words—ok if a little shorter Please do not accept if you are not familiar with nursing and informatics. =this must make sense Post a description of experiences or observations about how nurse informaticists and/or data or technology specialists interact with other professionals within your healthcare

Review the instructions for our informative speech outline assignment below.

   Review the instructions for our informative speech outline assignment below. Imagine yourself as the professor and your job is to grade the following Informative Outline submitted by a student. There are five mistakes in the outline pertaining to the basic format and assignment requirements. Your job is to identify

The reflection assignment is a seven (10)-page paper based knowledge

 The reflection assignment is a seven (10)-page paper based knowledge gained in the course. One topic is selected by the student from the following topics: Cultural Environments of Global Markets, Global Market Opportunities, and Global Market Strategies. The topic is then illustrated using a current event article from a credible

watch the two videos and write 1000 per video https://www.youtube.com/watch?v=d7YA0Dd6Hn0

watch the two videos and write 1000 per video  https://www.youtube.com/watch?v=lIsfCmPI0cU&t=1s 1) Overview/Description of Class Session: ● Link to video: ● School Name/District/Teacher Name – if identifiable: ● Type of classroom (grade/subject/special program): ● # of teachers and assistants / # of students – if identifiable: ● Briefly describe the demographic

You will be asked to read two short articles on

You will be asked to read two short articles on how companies are managing diversity. You will research other cases in the business news that highlight challenges in promoting diversity as well as best practices. The goal is for you to reflect on the positive impact of diversity management initiatives,

The following exercise allows you to practice collaboration skills to

The following exercise allows you to practice collaboration skills to develop transformational leadership strategies. Complete the case study exercise, Transformational Leadership.(see attachment, answer blue “Answer field” 25 – 50 words) Consider what you learned in the experience. APA format 175 – 265 words Cite at least one peer reviewed reference