Concept explainers
Easter Sunday is the first Sunday after the first full moon of spring. To compute the date, you can use this
- 1. Let y be the year (such as 1800 or 2001).
- 2. Divide y by 19 and call the remainder a. Ignore the quotient.
- 3. Divide y by 100 to get a quotient b and a remainder c.
- 4. Divide b by 4 to get a quotient d and a remainder e.
- 5. Divide 8 * b + 13 by 25 to get a quotient g. Ignore the remainder.
- 6. Divide 19 * a + b - d - g + 15 by 30 to get a remainder h. Ignore the quotient.
- 7. Divide c by 4 to get a quotient j and a remainder k.
- 8. Divide a + 11 * h by 319 to get a quotient m. Ignore the remainder.
- 9. Divide 2 * e + 2 * j - k - h + m + 32 by 7 to get a remainder r. Ignore the quotient.
- 10. Divide h - m + r + 90 by 25 to get a quotient n. Ignore the remainder.
- 11. Divide h - m + r + n + 19 by 32 to get a remainder p. Ignore the quotient.
Then Easter falls on day p of month n. For example, if y is 2001:
a = 6
b = 20, c = 1
d = 5, e = 0
g = 6
h = 18
j = 0, k = 1
m = 0
r = 6
n = 4
p = 15
Therefore, in 2001, Easter Sunday fell on April 15. Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
BIG JAVA: LATE OBJECTS
Additional Engineering Textbook Solutions
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
C++ How to Program (10th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Introduction to Programming Using Visual Basic (10th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- Given a positive integer 'n', find and return the minimum number of steps that 'n' has to take to get reduced to 1. You can perform any one of the following 3 steps:1.) Subtract 1 from it. (n = n - 1) ,2.) If its divisible by 2, divide by 2.( if n % 2 == 0, then n = n / 2 ) ,3.) If its divisible by 3, divide by 3. (if n % 3 == 0, then n = n / 3 ). Write brute-force recursive solution for this.Input format :The first and the only line of input contains an integer value, 'n'.Output format :Print the minimum number of steps.Constraints :1 <= n <= 200 Time Limit: 1 secSample Input 1 :4Sample Output 1 :2 Explanation of Sample Output 1 :For n = 4Step 1 : n = 4 / 2 = 2Step 2 : n = 2 / 2 = 1 Sample Input 2 :7Sample Output 2 :3Explanation of Sample Output 2 :For n = 7Step 1 : n = 7 - 1 = 6Step 2 : n = 6 / 3 = 2 Step 3 : n = 2 / 2 = 1 SolutionDp///.arrow_forwardAn integer is called squarefree if it is not divisible by any perfect squares other than 1. For instance, 42 is squarefree because its divisors are 1, 2, 3, 6, 7, 21, and 42, and none of those numbers (except 1) is a perfect square. On the other hand, 45 is not squarefree because it is divisible by 9, which is a perfect square. Write an algorithm that asks the user to enter a positive integer n and tells them if it is squarefree or not.arrow_forwardWrite an algorithm that reads 10 integer numbers and calculates the average for numbers that are divisible by 5.arrow_forward
- Fibonacci numbers have a lot of numerical properties. A few can be mentioned is that the squares of the Fibonacci numbers added together by the consecutive number you get the next Fibonacci number, and when you add the squares together it also results to the Fibonacci sequence. Another is when adding the squares of the Fibonacci numbers for example one plus one plus four is six. Add nine to that, we get 15. Add 25, we get 40. Add 64, we get 104. Fibonacci shows here. Six is two times three, 15 is three times five and so on. Last to be mentioned is when you divide 13 by eight, you get 1.625 and if you dividde this larger number by the smaller number, the ratios get closer and closer to about 1.618. Now the question is, what other numerical properties can you identify in the Fibonacci sequence ASIDE from those mentioned above and verify your assumptions.arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. You have two positive integers an and b. You can perform two sorts of tasks: a=⌊ab⌋ (supplant a with the integer part of the division among an and b) b=b+1 (increment b by 1) Track down the base number of activities needed to make a=0. Input The primary line contains a solitary integer t (1≤t≤100) — the number of experiments. The main line of the depiction of each experiment contains two integers a, b (1≤a,b≤109). Output For each experiment, print a solitary integer: the base number of activities needed to make a=0.arrow_forwardGiven two integers, a and b, return true if a can be divided evenly by b. Return false otherwise. Examples divides Evenly (98, 7) true // 98/7 = 14 → divides Evenly (85, 4) false // 85/4 = 21.25 → Notes a will always be greater than or equal to b.arrow_forward
- A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is Area = ( n * s2 ) / (4 * tan( π/n) Here, s is the length of a side. Write a program that prompts the user to enter the number of sides and their length of a regular polygon and displays its area.arrow_forwardAssume that start and end are integers.Return the average all of the numbers from start to end inclusive.For example,average(3, 5) returns 4.0, since (3 + 5) / 2 = 4arrow_forwardDecimal points are sometimes used in hotel room numbers . If you were assigned to room 6.10 , where would you expect to find it.arrow_forward
- One way to determine how healthy a person is by measuring the body fat of the person. The formulas to determine the body fat for female and male are as follows: Body fat formula for women: A1=(body weight*0.732)+8.987 A2=wrist measurement(at fullest point)/3.14053 A3=waist measurement(at navel)*0.15753 A4=hip measurement(at fullest point)*0.24953 A5=forearm measurement(at fullest point)*0.434 B=A1+A2-A3-A4+A5 Body fat=body weight-Barrow_forwardSimulate the dice game of lucky sevens. The rules are: roll two dice if the sum equals 7, win $4 if the sum is not 7, lose $1 Write a program that asks the user how much they would like start the game with. The program should then: simulate the dice roll (using the random function) and show what was rolled show what the user’s funds are after each roll ask the user if they want to roll again if the user wants to roll again, repeat the three actions above if the user does not want to roll again give some response and end the game the final output should show if they won or lost money, and how many rolls they playedarrow_forwardA positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is the first perfect number, because The next is There are four perfect numbers less than 10,000. Write a program to find these four numbers.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT