How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask ATLProg Your Own Question
ATLProg
ATLProg, Software Engineer
Category: Homework
Satisfied Customers: 9151
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
44910485
Type Your Homework Question Here...
ATLProg is online now
A new question is answered every 9 seconds

A. Write a Java program that: Asks for an integer value n; Then

This answer was rated:

A. Write a Java program that:
Asks for an integer value n;
Then asks for n number(s) from the user;
Finally displays the average of all the numbers typed in by the user.

B (5 points) Write a program segment in Java that sets the value of “int Number1” randomly from the following set: {2, 4, 6, 10}.

C (5 points) Write a method Power(base, exponent) that returns the value of

base ^exponent;

(Assume that exponent is a positive, non-zero double and base is a double.)

2. (A) A program sorts an array’s elements into descending order. The array contains 5 elements. How many steps would sorting take (at most)?
(B) Write a program that rolls a FOUR-sided die 20 times and stores results in int a[20].
(C) What does the following program print? Why? Explain with your own words.

public class Program
{
public static void main (String [] args)
{
final int arraySize =5;
int a[] = { 1, 2, 3, 4, 5 };
int result = whatIsThis(a, arraySize);
System.out.printf("Result is : %d.\n", result);
}
public static int whatIsThis(int b[], int size)
{
if ( size == 1 )
return b[ 0 ];
else
return 2 * (b[ size - 1 ] ) + whatIsThis(b, size - 1 );
}
}

3. (A) (Complex Numbers) Create a class called Complex for performing arithmetic with complex numbers. Complex numbers have the form

realPart + imaginaryPart * i

where i is square root of -1



Write a program to test your class. Use floating-point variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared. Provide a no-argument constructor with default values in case no initializers are provided. Provide public methods that perform the following operations:

a) Add two Complex numbers: the real parts are added together and the imaginary parts are added together.
Hint:
For this exercise, please consider the use of this reference.
A template looks like:

// Add two Complex numbers
public Complex add( Complex Right )
{
/* Write code here */
}
b) Subtract two Complex numbers: the real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the right operand is subtracted from the imaginary part of the left operand.
c) Print Complex numbers in the form (a, b), where a is the real part and b is the imaginary part.

(B) Write a program that inputs five numbers, each of which is between 10 and 100, inclusive. As each number is XXXXX display it only if it is not a duplicate of a number already read.

4. (A) Create a class of Circles with attribute radius that defaults to 1. (It must be positive for every circle.) Provide member methods that calculate the perimeter and the area of the circle. Also, provide set and get methods for the radius attribute.
(Hint: perimeter = 2*radius*pi; and area = radius*radius*pi; pi is a constant, can be set to 3.14 here.)



5. Write a program that creates a queue of integers. After that it loads in 20 random integers between 1 and 6, and after the 20th number it prints out the content of the queue. Finally, the program calculates and prints out the average of the values without losing the values from the queue!

6. Create a class of Circle with attributes radius, X and Y that represent the Cartesian coordinates of the center point. Radius default value is 1, it must be positive for every circle. Provide a member method Cross that returns true if two circles cross each other. Otherwise it returns false. Cross has a Circle object input parameter.
Hello Welcome. Thank you for your question, I’m ATLProg and I’ll try to help you.

How soon do you need this answer ?
Customer: replied 3 years ago.

I need it by tomorrow. I see that you have completed similar homework for someone else this week. The only difference I see is in problem 1B the set of numbers are {2, 4, 6, 10}. And in problem 2A a four sided die 20 times / int a[20]


 

I can send the answers to you, current price of question is incorrect... I have sent a Underpriced report on this to your registered email id, please confirm if the price looks ok to you. Please let me know so I can start working on this accordingly.
Customer: replied 3 years ago.

Increase in price? You have already answered the same questions just yesterday.

Sorry, but it would be unfair if I give it out at a diff price than what I gave them to the other customer..
Customer: replied 3 years ago.

Well how much for just these questions?


 


1: Write a Java program that:
Asks for an integer value n;
Then asks for n number(s) from the user;
Finally displays the average of all the numbers typed in by the user.

2: Write a program segment in Java that sets the value of “int Number1” randomly from the following set: {2, 4, 6, 10}.



3: What does the following program print? Why? Explain with your own words.

public class Program
{
public static void main (String [] args)
{
final int arraySize =5;
int a[] = { 1, 2, 3, 4, 5 };
int result = whatIsThis(a, arraySize);
System.out.printf("Result is : %d.\n", result);
}
public static int whatIsThis(int b[], int size)
{
if ( size == 1 )
return b[ 0 ];
else
return 2 * (b[ size - 1 ] ) + whatIsThis(b, size - 1 );
}
}



4. Create a class of Circle with attributes radius, X and Y that represent the Cartesian coordinates of the center point. Radius default value is 1, it must be positive for every circle. Provide a member method Cross that returns true if two circles cross each other. Otherwise it returns false. Cross has a Circle object input parameter.

I can give these for current price of question
Customer: replied 3 years ago.

Great.

ok, will send it out in a few..stay here
THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
ATLProg and 2 other Homework Specialists are ready to help you
Are we all good ? I hope I’ve provided the information you were seeking. If you are happy with my service, please provide a rating. If not, please let me know so l can continue to help you. Thank you.
Customer: replied 3 years ago.

In problem (c) - why is the result 29.


 


the circle problem does not compile and execute when I try to run it.


 


Create a class of Circle with attributes radius, X and Y that represent the Cartesian coordinates of the center point. Radius default value is 1, it must be positive for every circle. Provide a member method Cross that returns true if two circles cross each other. Otherwise it returns false. Cross has a Circle object input parameter.


this is the picture in the problem




what error are you seeing with the Circle question ?
Customer: replied 3 years ago.

Error: Main method not found in class Circle, please define the main method as:
public static void main(String[] args)

its not supposed to run, we are only to create a class here
Customer: replied 3 years ago.

okay.


 


In problem (c) - why is the result 29?

I will send that in a few...pls go ahead and rate the answer meanwhile and I will send the explanation as soon as answer is rated

Result is : 29.

We are using recursion to achieve the result whatIsThis method I called inside whatIsThis method with return condition of size = 1. When we get to size ==1 we return b[0] which is 1
Customer: replied 3 years ago.

Thank you for all your help.

welcome

Related Homework Questions