• API
• FAQ
• Tools
• Archive
daily pastebin goal
13%
SHARE
TWEET

# Untitled

Arush22 Jan 18th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
2. package com.company;
3.
4. public class Point
5. {
6.
7.     private int x;
8.     private int y;
9.     public Point() //Default constructor
10.     {
11.         x=0;
12.         y=0;
13.     }
14.     public Point(int x1, int y1) //Default constructor
15.     {
16.         x = x1;
17.         y = y1;
18.     }
19.     public void setX(int x1)
20.     {
21.         x = x1;
22.     }
23.     public void setY(int y1)
24.     {
25.         y = y1;
26.     }
27.     public int getX()
28.     {
29.         return x;
30.     }
31.     public int getY()
32.     {
33.         return y;
34.     }
35.     public void PrintPoint()
36.     {
37.         System.out.println("Point p1 = ("+x+","+y+")");
38.     }
39.     public double DistanceToOrigin()
40.     {
41.         return (Math.sqrt(x*x+y*y));
42.     }
43.     public void translatePoint(int dx, int dy)
44.     {
45.         x = x + dx;
46.         y = y + dy;
47.     }
48.
49. }
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65. package com.company;
66. import java.text.DecimalFormat;
67. public class ClientPoint {
68.     public static void main (String[] args){
69.
70.         Point p1 = new Point();
71.
72.         Point p2 = new Point();
73.
74.         DecimalFormat distanceFormat = new DecimalFormat("#0.00");
75.         System.out.println(" The distance is "+distanceFormat.format(p2.DistanceToOrigin()));
76.
77.         p1.PrintPoint();
78.
79.         double distance = p1.DistanceToOrigin();
80.         System.out.println(distance);
81.
82.         p2.setX(-3);
83.         Point p3 = new Point();
84.         p3.setX(p2.getX()); // set value of p3 to p2.
85.
86.         p3.translatePoint(3,4);
87.         p3.PrintPoint();
88.
89.     }
90. }
91.
92.
93.
95. package com.company;
96. /*
98.    1/15/2019
99.    Reads and states sentence types
100.  */
101. import java.util.*;
102. import java.lang.*;
103.
104. public class Decrypter {
105.     public static void main(String[] args)
106.     {
107.         Scanner input = new Scanner(System.in);
108.         System.out.println("Please type a string with nine characters or more below");
109.         String sentence = input.next();
110.
111.         char character1 = sentence.charAt(0); // reads first char
112.         char character2 = sentence.charAt(2); // reads third char
113.         char character3 = sentence.charAt(4); // reads fifth char
114.         char character4 = sentence.charAt(6); // reads seventh char
115.         char character5 = sentence.charAt(8); // reads ninth char
116.         int stringlength = sentence.length();
117.
118.         if(stringlength>=9){
119.             System.out.println(character1+character2+character3+character4+character5);
120.         }
121.         else{
122.             System.out.println("invalid input.");
123.         }
124.     }
125. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top