Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In JAVA Plz Write a class, Mod9, that performs modulo 9 arithmetic. What this means is that a Mod9 object can only hold integers from

In JAVA Plzimage text in transcribed

Write a class, Mod9, that performs modulo 9 arithmetic. What this means is that a Mod9 object can only hold integers from 0 to 8 and the value is determined by taking the absolute value and applying '% 9' (the remainder operator followed by 9). When converting Mod9 numbers to strings (using the _____str _____function) surround the value with " ". Here is the UML for the class: -value: int +Mod9(value: int = 0) +add (n2: Mod9): Mod9 +subract(n2: Mod9): Mod9 +multiply(n2: Mod9): Mod9 +toString(): String The following test program: import java util. Scanner public class TestMod9{ public static void main (String[] args) { System out.println.("" + Mod9 (1) + "" + Mod9 (-14) + "" + Mod9 (234)): Mod9 m1 = new Mod9 (44): Mod9 m2 = new Mod9 (78): Mod9 m3 = m1. multiply (m2): Mod9 m4 = m2. subtract (m2): Mod9 m5 = m1. add (m2): System out.println (m1 "" + m2 + "" + m3 + "" + m4 + "" + m5): } } should give this output:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions