1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kirill [66]
3 years ago
11

Programming Exercise 11 in Chapter 8 explains how to add large integers using arrays. However, in that exercise, the program cou

ld add only integers of, at most, 20 digits. This chapter explains how to work with dynamic integers. Design a class named largeIntegers such that an object of this class can store an integer of any number of digits. Add operations to add, subtract, multiply, and compare integers stored in two objects. Also add constructors to properly initialize objects and functions to set, retrieve, and print the values of objects. Write a program to test your class.
Computers and Technology
1 answer:
Marat540 [252]3 years ago
5 0

Answer:

Explanation:

The following is written in Java. It creates a class called largeIntegers that creates objects of the built-in BigInteger class to handle operations on very large numbers. The class contains the add, subtract, multiply, compare, toString methods as well as the getter and setter method for the BigInteger. A test class has been provided and the output can be seen in the attached picture below where two numbers are created and added together. Due to technical difficulties, I have added the code as a txt file below.

You might be interested in
Select four tasks associated with operating system maintenance. Cleaning inside the computer Defragmenting the hard drive Deleti
hram777 [196]

Answer:

Cleaning inside the computer

Defragmenting the hard drive

Deleting temporary files

Organizing data

Explanation:

7 0
2 years ago
What describes a group of cells?<br> O crowd<br> Orange<br> O set<br> gangle
deff fn [24]

Answer:

A crowd because it makes more sense tho i could be wrong

7 0
2 years ago
Read 2 more answers
.Choose the extention of Scratch Project<br><br><br> .sb2<br><br> jpeg<br><br> .exls
Ratling [72]

Answer:

I know about .sb3, and it similar to .sb2

that might be your answer.

Explanation:

jpeg is for pictures and .exls is Microsoft's excel

extension.

4 0
3 years ago
Read 2 more answers
Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l
alexandr1967 [171]

Answer:

a=input("Amount in pennies")

b=int(a)

dollars=0

dimes= 0

quarters=0

nickels=0

pennies = 0

dollars = int(b/100)

b= b- dollars *100

quarters=int(b/25)

b=b-quarters*25

dimes = int(b/10)

b = b -dimes*10

nickels=int(b/5)

b=b - nickels * 5

pennies = b

print(dollars)

print(dimes)

print(nickels)

print(pennies)

Explanation:

The required program is in answer section. Note, the amount is entered in pennies.

7 0
3 years ago
Write a function called factor that determines for a pair of integers whether the second integer is a factor of the first. The f
Aleks04 [339]
<h2>Answer:</h2>

//import the Scanner class to allow for user's input

import java.util.Scanner;

//Declare the class and call it FactorClass

public class FactorClass {

   

   //Declare the function factor

   //It returns either true or false, therefore the return type is boolean

   //It receives two arguments - a and b

   public static boolean factor(int a, int b){

       

       //Check if a is divisible by b.

       //Return true if yes

       if(a % b == 0){

           return true;

       }

       

       //return false if a is not divisible by b

       return false;

   

   }  // End of method factor

   

   

   //The main method to test the function factor()

   public static void main(String[] args) {

       

       //Create an object of the Scanner class

       Scanner input = new Scanner(System.in);

       

       //Prompt the user to enter the pair of numbers

       System.out.println("Enter the pair of numbers (separated by a space)");

       

       //grab and store the first number in a variable

       int firstnum = input.nextInt();

       

       //grab and store the second number in another variable

       int secondnum = input.nextInt();

       

       

       //With the variables, call the factor() method

       //If it returns true, print the adequate message

       if(factor(firstnum, secondnum)){

           System.out.println(secondnum + " is a factor of " + firstnum);

       }

       

       //If it returns false, print the adequate message

       else{

           System.out.println(secondnum + " is NOT a factor of " + firstnum);

       }

   

 }            // End of main method

   

}    // End of class declaration

==============================================================

<h2>Sample Output 1:</h2>

>> Enter the pair of numbers  separated by a space

8 4

>> 4 is a factor of 8

==============================================================

<h2>Sample Output 2:</h2>

>> Enter the pair of numbers  separated by a space

9 4

>> 4 is NOT a factor of 9

==============================================================

<h2>Explanation:</h2>

The above code has been written in Java and it contains comments explaining every segment of the code. Kindly go through the comments for better understanding of the code.

For simplicity, the code is re-written as follows with little or no comments;

import java.util.Scanner;

//Declare the class and call it FactorClass

public class FactorClass {

   

   public static boolean factor(int a, int b) {

       if(a % b == 0){

           return true;

       }

       

       //return false if a is not divisible by b

       return false;

   

   }  // End of method factor

   

   

   //The main method to test the function factor()

   public static void main(String[] args) {

       

       //Create an object of the Scanner class

       Scanner input = new Scanner(System.in);

       

       //Prompt the user to enter the pair of numbers

       System.out.println("Enter the pair of numbers (separated by a space)");

       

       //grab and store the first number in a variable

       int firstnum = input.nextInt();

       

       //grab and store the second number in another variable

       int secondnum = input.nextInt();

       

       

       if(factor(firstnum, secondnum)){

           System.out.println(secondnum + " is a factor of " + firstnum);

       }

       

       else{

           System.out.println(secondnum + " is NOT a factor of " + firstnum);

       }

    }

   

}

3 0
3 years ago
Other questions:
  • The ____ contains methods that allow you to set physical properties such as height and width, as well as methods that allow you
    14·1 answer
  • Sue conducted an experiment to determine which paper towel is the most absorbent among three different brands. She decides to pr
    15·1 answer
  • Why do clocks tick-toc?
    5·2 answers
  • Side mirror using convex mirror or concave mirror?​
    5·2 answers
  • Write code statements to create a DecimalFormat object that will round a formatted value to four decimal places. Then write a st
    15·1 answer
  • Which is an example of an input device?
    15·2 answers
  • To access WordPad, Jill will click on Start, All Programs, Accessories, and WordPad. To access Notepad, Karl will click on Start
    5·1 answer
  • "This part of the computer fetches instructions, carries out the operations commanded by the instructions, and produces some out
    15·1 answer
  • Which type of film would typically require the least amount of input from a screenwriter?
    10·1 answer
  • Can someone help me debug this please
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!