Ask Computer Engineering Expert

1. Design and implement an application that reads an integer value representing a year from the user. The purpose of the program is to determine if the year is a leap year (and therefore, has 29 days in February) in the Gregorian calendar. A year is a leap year if it is divisible by 4, unless it is also divisible by 100, but not 400. For ex, the year 2003 is not a leap year, but 2004 is. The year 1900 is not a leap year because it is divisible by 100, but the year 2000 is a leap year because even though it is divisible by 100, it is also divisible by 400. Produce an error message for any input values less than 1582 (the year the Gregorian calendar was adopted).

2. Implement a method called allEven that takes an integer parameter end. The method returns the sum of all even integers between 2 and end, inclusive. Return -1 if the end value is less than 2.

3. Implement a method named outlier that will generate a random number from 1 - 30. It will return true if the number is less than 10 or greater than 20. 

4. Implement a method named digits that takes one integer parameter named num. The method will return the number of digits in the integer.
You CANNOT use any methods of the String or Integer Wrapper Classes

ex: (if the integer is 342712) the method will return: 6 // (number of digits) 
NOTE: Remember to put all methods in a class for testing (As you did in Homework 4).

5. [20 points] Define a class MonetaryCoin with 2 instance data, a string face, which can be "head" or "tail" and an int value that represents the monetary value of the coin. The following method should be included in the class:
- a default constructor
- a constructor that takes 2 parameters to initialize instance data
- a getter for each instance data
- a setter method for each instance data
- a toString method that returns the coin's face and monetary value
- a method flip() that randomly sets the face to either "head" or "tail"
- a method add() that takes another MonetaryCoin parameter and returns the sum of their monetary values.
- an equals() method that compares two monetary coins and returns true if they have same face and value and false otherwise.

6. Using the MonetaryCoin class defined above, design and implement a driver class called FlipRace whose main method creates two MonetaryCoin objects, with face and value entered from the keyboard. It then continually flips them both to see which coin first comes up heads three flips in a row. Continue flipping the coins until one of the coins wins the race, and consider the possibility that they might tie. Print the results of each turn, and at the end print the winner and total number of flips that were required.

7. Using the MonetaryCoin class defined above, design and implement a driver class called FlipApp whose main method crates two MonetaryCoin objects, with face and same monetary value entered from the keyboard. The method flips the coins 100 times and prints to the screen the total number of times both coins were equal. It should then print the information about each coin as well as their sum.

8. Using the PairOfDice class from previous homework, design and implement an application that rolls a pair of dice 1000 times, counting the number of box cars (two sixes) that occur. 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M994076
  • Price:- $60

Guranteed 36 Hours Delivery, In Price:- $60

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As