Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code for the first program:
- package com.Suarez;
- /*
- Xander Fermier
- 1/17/19
- this program instantiates two points and reads their data.
- */
- import java.util.*;
- import java.text.*;
- public class PointClientHW {
- public static void main(String[]args)
- {
- Scanner pointDelcare = new Scanner(System.in);
- System.out.println("Give me your x value for the first point.");
- int x1 = pointDelcare.nextInt();
- System.out.println("Give me your y value for the first point.");
- int y1 = pointDelcare.nextInt();
- System.out.println("Give me your x value for the second point.");
- int x2 = pointDelcare.nextInt();
- System.out.println("Give me your y value for the second point.");
- int y2 = pointDelcare.nextInt();
- Point p1 = new Point(x1,y1);
- Point p2 = new Point(x2,y2);
- System.out.println("The first point is (" + p1.getX() + ", " + p1.getY()+ ")");
- System.out.println("The second point is (" + p2.getX() + ", " + p2.getY()+ ")");
- }
- }
- The code for the second program:
- package com.Suarez;
- /*
- Xander Fermier
- 1/17/19
- This program decrypts the message that the user has input and then outputs the result
- */
- import java.util.*;
- public class SentenceDecrypter {
- public static void main(String[]args)
- {
- Scanner sentence = new Scanner(System.in);
- System.out.println("Give me your encrypted message.");
- String userSentence = sentence.nextLine();
- // gets the char values from the user
- char first = userSentence.charAt(0);
- char second = userSentence.charAt(2);
- char third = userSentence.charAt(4);
- char fourth = userSentence.charAt(6);
- char fifth = userSentence.charAt(8);
- // assembles the char values into the message
- StringBuilder sb = new StringBuilder();
- sb.append(first);
- sb.append(second);
- sb.append(third);
- sb.append(fourth);
- sb.append(fifth);
- String message = sb.toString();
- System.out.println("The message is: " + message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement