java - Trying to use toString to plot coordinates -


this description of assignment i'm stuck trying use tostream. don't want answer guidance problem , using point class in java. thank guys!

"prompt user 4 integer values: x1, y1, x2, y2 represent (x,y) coordinates 2 points on plane p1 , p2 respectively. using point class java class library. create 2 point objects p1 , p2 input data, print data both point objects utilizing tostring method."

import java.util.scanner; public class point {     public static void main(string[] args) {    scanner keyboard = new scanner(system.in);   int x1, x2, y1, y2;    system.out.println("please enter first x coordinate!");   x1 = keyboard.nextint();   system.out.println("please enter second x coordinate!");   x2 = keyboard.nextint();   system.out.println("please enter first y coordinate!");   y1 = keyboard.nextint();   system.out.println("please enter second y coordinate!");   y2 = keyboard.nextint();   point p1 = new point();  point p2 = new point();   p1.tostream(x1,y1);   }    } 

you need initialize point objects give them value , print them out using tostring, not tostream.

below code should work need do, stop reading here if want try yourself.


int x1, y1, x2, y2;  ...  point p1 = new point(x1, y1), p2 = new point(x2, y2); system.out.println(p1); system.out.println(p2); // use p1.tostring() , p2.tostring() here instead, println(object o) calls #tostring() on object. 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -