Answered step by step
Verified Expert Solution
Link Copied!

Question

...
1 Approved Answer

Create a new BlueJ project called YourFirstNameLastName-A1T2. Create a class called NumberChecking. Make sure you write a description of your new Class in the

image text in transcribed image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Create a new BlueJ project called YourFirstNameLastName-A1T2. Create a class called NumberChecking. Make sure you write a description of your new Class in the comments, with your name as author and date as the last date you worked on this exercise. Add definitions for the following fields: A number field of type double. A result field of type int. A remainder field of type int. Write a constructor that has one parameter of the double type. Please note that the parameter takes any values, including positive, negative, whole or fractional numbers. Implement the following inside the constructor. Initialise the number field with the constructor parameter. Initialise result and remainder fields with zero (0). If the number field holds a negative integer, compute its absolute value and assign it to the result field. If the number field holds a positive integer, compute the division of the number by two (2). Assign the remainder of this division to the remainder field. Assign the quotient of the division to the result field. Write a method checkNumberType() that first checks if the value held by the number field has a decimal part or not. If it has a decimal part, print "The number XY has a decimal part", and print "The number XY does not have a decimal part". After this, check if the value inside the number field is an even number. Print "The number XY is an even number" if it is an even number, otherwise print "The number XY is an odd number". Please add comments to describe the class, fields, and methods. Assignment 1 Task 3 To be completed in week 2 Create a new BlueJ project called YourFirstNameLastName-A1T3. Make sure you write a description of your new Class DigiClock in the comments, with your name as author and give the version as the date you last worked on this exercise. Part A: Imagine you need to write a program for a 24-hour clock with hours, minutes and seconds, e.g., hh:mm:ss. Write a method printAllClockCombinations() that takes three (3) parameters - hours, minutes, and seconds. This method prints all possible times the clock could display starting at 00:00:00 through to 23:59:59 when all the three numbers (hours, minutes and seconds) are the same (e.g. 01:01:01, 02:02:02, 13:13:13 and so on). You need to use loop(s) to implement this method. Write a second method printSomeClockCombinations() that takes three (3) parameters - hours, minutes, and seconds. This method will print out all of the possible times the clock could display from one hour before the time passed to the method till one hour after the time passed to the method when the number for minutes is an odd number (e.g. 12:19:00 or 13:21:01, NOT 12:20:01). For example: If the method was passed the following values: Hour = 11 Minutes = 24 Seconds = 44 The method would print all the times the clock could display from 10:24:44 until 12:24:44 when the minutes is an odd number. The first printed time would be 10:25:00, and the last one would be 12:23:59). You need to use loop(s) to implement this method. Please add comments to describe the class and methods. Assignment 1 Task 4 To be completed in week 2 Create a new BlueJ project called Your FirstNameLastName-A1T4. Create a class, ModuloOperator. Make sure you write a description of your new Class in the comments, with your name as author and give the version as the date you last worked on this exercise. Write a constructor that has two int parameters - dividend, and length. The length is how many digits the dividend has. The constructor has two local variables divisor and base of int type. You need to implement a method so that it will print the number pattern, as shown in the sample outputs below: Sample input (provided while creating an object of the class): dividend = 987654321, length = 9 Sample output: 987654321 87654321 7654321 654321 54321 4321 321 21 1 Sample input (provided while creating an object of the class): dividend = 123456, length = 6 Sample output: 123456 23456 3456 456 56 6 Implementation instructions: Your implementation is required to follow a number of instructions that are mentioned below. The variable names (dividend, divisor, base, length) may give you some ideas about what their roles would be. You need to use only one loop. You need to use a modulo operation. The divisor would be an exponent of the base (you need to figure out what the base should be). Please add comments to describe the class, and methods.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Operations Research

Authors: Frederick S. Hillier, Gerald J. Lieberman

10th edition

978-1259162985

More Books

Students also viewed these Programming questions

Question

127. Identify four specialized financial analysis tools.

Answered: 1 week ago

Question

125. Identify and describe limitations of ratio analysis.

Answered: 1 week ago