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: 8624
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
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

Customer Question

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.
Submitted: 11 months ago.
Category: Homework
Expert:  ATLProg replied 11 months ago.
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 11 months 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]


 

Expert:  ATLProg replied 11 months ago.
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 11 months ago.

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

Expert:  ATLProg replied 11 months ago.
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 11 months 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.

Expert:  ATLProg replied 11 months ago.
I can give these for current price of question
Customer: replied 11 months ago.

Great.

Expert:  ATLProg replied 11 months ago.
ok, will send it out in a few..stay here
Expert:  ATLProg replied 11 months ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
ATLProg, Software Engineer
Category: Homework
Satisfied Customers: 8624
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
ATLProg and 13 other Homework Specialists are ready to help you
Expert:  ATLProg replied 11 months ago.
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 11 months 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




Expert:  ATLProg replied 11 months ago.
what error are you seeing with the Circle question ?
Customer: replied 11 months ago.

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

Expert:  ATLProg replied 11 months ago.
its not supposed to run, we are only to create a class here
Customer: replied 11 months ago.

okay.


 


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

Expert:  ATLProg replied 11 months ago.
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
Expert:  ATLProg replied 11 months ago.

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 11 months ago.

Thank you for all your help.

Expert:  ATLProg replied 11 months ago.
welcome

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience