Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 5.import java.util.*;
- public class Project5
- {
- public static void main(String [] args)
- {
- Scanner pikachu = new Scanner(System.in);
- System.out.print("What is the distance between your two locations?");
- System.out.print("Input your first latitude");
- String degrees1 = pikachu.nextLine();
- double lat1 = Double.parseDouble(degrees1.substring(2));
- System.out.print("Input your first latitude minutes");
- double min1 = pikachu.nextDouble();
- if(degrees1.startsWith("S"))
- {
- lat1 = lat1*-1;
- min1 = min1*=1;
- }
- Scanner pikachu2 = new Scanner(System.in);
- System.out.print("Input your first longitude");
- String degrees2 = pikachu2.nextLine();
- double long1 = Double.parseDouble(degrees2.substring(2));
- System.out.print("Input your first longtitude minutes");
- double min2 = pikachu2.nextDouble();
- if(degrees2.startsWith("W"))
- {
- long1 = long1*-1;
- min2 = min2*-1;
- }
- Scanner pikachu3 = new Scanner(System.in);
- System.out.print("Input your second latitude");
- String degrees3 = pikachu3.nextLine();
- double lat2 = Double.parseDouble(degrees3.substring(2));
- System.out.print("Input your second latitude minutes");
- double min3 = pikachu3.nextDouble();
- if(degrees3.startsWith("S"))
- {
- lat2 = lat2*-1;
- min3 = min3*-1;
- }
- Scanner pikachu4 = new Scanner(System.in);
- System.out.print("Input your second longitude");
- String degrees4 = pikachu4.nextLine();
- double long2 = Double.parseDouble(degrees4.substring(2));
- System.out.print("Input your second longitude minutes");
- double min4 = pikachu.nextDouble();
- if(degrees4.startsWith("W"))
- {
- long2 = long2*-1;
- min4 = min4*-1;
- }
- double sphericaldiff = Calculation(lat1, min1, long1, min2, lat2, min3, long2, min4);
- System.out.println("Your spherical distance between location a and location b is"+sphericaldiff);
- }
- public static double Calculation(double lat1, double min1, double long1, double min2, double lat2, double min3, double long2, double min4)
- {
- double latitude1 = Math.toRadians(lat1+(min1/60));
- double longitude1 = Math.toRadians(long1+(min2/60));
- double latitude2 = Math.toRadians(lat2+(min3/60));
- double longitude2 = Math.toRadians(long2+(min4/60));
- double longdiff = longitude2-longitude1;
- double angulardistance = Math.acos(Math.sin(latitude1)*Math.sin(latitude2)+Math.cos(latitude1)*Math.cos(latitude2)*Math.cos(longdiff));
- double sphericaldiff = 6372.795*angulardistance;
- return sphericaldiff;
- }
- }
- 6.import java.util.*;
- public class Project6
- {
- public static void main(String [] args)
- {
- Scanner pikachu = new Scanner(System.in);
- System.out.println("!!!!!Its Calendar Time!!!!!");
- System.out.print("Input the amount of days in the month");
- double days = pikachu.nextInt();
- System.out.print("Input the first Sunday of the week");
- double sunday = pikachu.nextInt();
- int control = 0;
- System.out.println(" Sun Mon Tue Wed Thu Fri Sat ");
- System.out.println("+------+------+------+------+------+------+------+");
- if(sunday == 2)
- {
- for(int space = 1; space <=6; space++)
- {
- System.out.print("| ");
- control = 1;
- }
- }
- if(sunday == 3)
- {
- for(int space = 1; space <=5; space++)
- {
- System.out.print("| ");
- control = 2;
- }
- }
- if(sunday == 4)
- {
- for(int space = 1; space <=4; space++)
- {
- System.out.print("| ");
- control = 3;
- }
- }
- if(sunday == 5)
- {
- for(int space = 1; space <=3; space++)
- {
- System.out.print("| ");
- control = 4;
- }
- }
- if(sunday == 6)
- {
- for(int space = 1; space <=2; space++)
- {
- System.out.print("| ");
- control = 5;
- }
- }
- if(sunday == 7)
- {
- for(int space = 1; space <=1; space++)
- {
- System.out.print("| ");
- control = 6;
- }
- }
- for(int day = 1; day <= days; day++)
- {
- if(day <= 9)
- {
- System.out.print("| "+day+" ");
- }
- if(day >= 10)
- {
- System.out.print("| "+day+" ");
- }
- if(day == control || day == control+7 || day == control+14 || day == control+21 || day == control+28)
- {
- System.out.println("|");
- }
- }
- if(days == 31)
- {
- if(sunday == 1)
- {
- for(int blank = 1; blank<=4; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 2)
- {
- for(int blank = 1; blank<=5; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 3)
- {
- for(int blank = 1; blank<=6; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 4)
- {
- for(int blank = 1; blank<=0; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 5)
- {
- for(int blank = 1; blank<=1; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 6)
- {
- for(int blank = 1; blank<=2; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 7)
- {
- for(int blank = 1; blank<=3; blank++)
- {
- System.out.print(" |");
- }
- }
- }
- if(days == 30)
- {
- if(sunday == 1)
- {
- for(int blank = 1; blank<=5; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 2)
- {
- for(int blank = 1; blank<=6; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 3)
- {
- for(int blank = 1; blank<=0; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 4)
- {
- for(int blank = 1; blank<=1; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 5)
- {
- for(int blank = 1; blank<=2; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 6)
- {
- for(int blank = 1; blank<=3; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 7)
- {
- for(int blank = 1; blank<=4; blank++)
- {
- System.out.print(" |");
- }
- }
- }
- if(days == 29)
- {
- if(sunday == 1)
- {
- for(int blank = 1; blank<=6; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 2)
- {
- for(int blank = 1; blank<=0; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 3)
- {
- for(int blank = 1; blank<=1; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 4)
- {
- for(int blank = 1; blank<=2; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 5)
- {
- for(int blank = 1; blank<=3; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 6)
- {
- for(int blank = 1; blank<=4; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 7)
- {
- for(int blank = 1; blank<=5; blank++)
- {
- System.out.print(" |");
- }
- }
- }
- if(days == 28)
- {
- if(sunday == 1)
- {
- for(int blank = 1; blank<=0; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 2)
- {
- for(int blank = 1; blank<=1; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 3)
- {
- for(int blank = 1; blank<=2; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 4)
- {
- for(int blank = 1; blank<=3; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 5)
- {
- for(int blank = 1; blank<=4; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 6)
- {
- for(int blank = 1; blank<=5; blank++)
- {
- System.out.print(" |");
- }
- }
- if(sunday == 7)
- {
- for(int blank = 1; blank<=6; blank++)
- {
- System.out.print(" |");
- }
- }
- }
- System.out.println("|");
- System.out.print("+------+------+------+------+------+------+------+");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement