Tuesday, July 28, 2009

Are you good with Java applications and programming? Help me please?

Do you know how I would go about setting these applications up, I know how to set up a main method, and some other basic components,...but some others I'm somewhat lost in...If you could help me type out these applications (in the Java format) I would be soooooooo grateful and consider you a complete and heroic lifesaver....so please....help me. =)





2. Write an application that reads the (x,y) coordinates for two points. Compute the distance between the two points using the following formula:


Distance = (x2 – x1)2 + (y2 – y1)2





3. Write an application that reads the radius of a sphere and printsits volume and surface area. Use the following formulas. Print the output to four decimal places, r represents the radius.


Volume = 4/3п r3


Surface area = 4п r2





4. Write an application that reads the lengths of the sides of a triangle from the user. Compute the area of the triangle using Heron's formula (below), in which 5 is half of the perimeter of the triangle, and a, b, and c are the lengths of the three sides. Print the area to three decimal places.


Area = s(s -d)(s- b)(s - c)





5. Write an application that creates and prints a random


phone number of the form XXX-XXX-XXXX. Include the dashes in the output. Do not let the first three digits contain an 8 or 9 (but don't be more restrictive than that), and make sure that the second set of three digits is not greater than 742. Hint: Think through the easiest way to construct the phone number. Each digit does not have to be determined separately.

Are you good with Java applications and programming? Help me please?
Will as the intend of Yahoo is to answer questions, i'll not be so mean and i'll help you with the first one only, you need to figure the rest by your own (u need to work more on your self):








public class distance{


public static void main(String args[]){


try


{


java.io.DataInput in = new java.io.DataInputStream(System.in);


System.out.println("Insert x1");


int x1=Integer.parseInt(in.readLine());





System.out.println("Insert x2");


int x2=Integer.parseInt(in.readLine());





System.out.println("Insert y1");


int y1=Integer.parseInt(in.readLine());





System.out.println("Insert y2");


int y2=Integer.parseInt(in.readLine());





int dist = ((x2-x1)*2) + ((y2-y1)*2);


System.out.println("The distance is: "+dist);


}


catch(Exception ex){System.out.print(ex);}


}


}
Reply:Ok, so why are you waiting till the last minute to do all that hmwk??? If you are not good with this it is because you haven't done it all semester. They wouldn't be asking these questions if that wasn't where they are at...why aren't you???





Give me some code on each answer and I will correct it. But not write it all.





All you have to do is make a variable for each number you are going to use (whether the number is assigned or you get it from a user). Then plug that number into the formula's.
Reply:Your first "formula" makes no sense, and would return (if worked) anything BUT distance. Quite frankly, I do enough programming at work to do your homework - search for a free manual online, there are plenty of them!
Reply:I'm still taking courses in programming. I've learned HTML, XHTML, CSS, and currently I'm learning JavaScript. I haven't taken Java.


No comments:

Post a Comment