lab3
This commit is contained in:
		
							
								
								
									
										22
									
								
								labs/lab3/Cards.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								labs/lab3/Cards.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | public class Cards { | ||||||
|  |     public enum Rank { | ||||||
|  |         ace, two, three, four, five, six, seven, eight, nine, ten, jack, queen, king | ||||||
|  |     } | ||||||
|  |     public static void main(String args[]){ | ||||||
|  |         Rank highCard; | ||||||
|  |         Rank faceCard; | ||||||
|  |         Rank card1; | ||||||
|  |         Rank card2; | ||||||
|  |  | ||||||
|  |         highCard = Rank.ace; | ||||||
|  |         faceCard = Rank.queen; | ||||||
|  |         card1 = Rank.four; | ||||||
|  |         card2 = Rank.six; | ||||||
|  |  | ||||||
|  |         int card1Val = card1.ordinal() + 1; | ||||||
|  |         int card2Val = card2.ordinal() + 1; | ||||||
|  |  | ||||||
|  |         System.out.println("High card : "+highCard+" and Face card: "+faceCard); | ||||||
|  |         System.out.println("Card 1: "+ card1Val+" Card 2: "+card2Val); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								labs/lab3/Distance.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								labs/lab3/Distance.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | |||||||
|  | // *************************************************************  | ||||||
|  | // Distance.java  | ||||||
|  | //  | ||||||
|  | // Computes the distance between two points  | ||||||
|  | // *************************************************************  | ||||||
|  | import java.util.Scanner;  | ||||||
|  | public class Distance  | ||||||
|  | {  | ||||||
|  |  public static void main (String[] args)  | ||||||
|  |  {  | ||||||
|  |  double x1, y1, x2, y2; // coordinates of two points  | ||||||
|  |  double distance; // distance between the points  | ||||||
|  |  Scanner scan = new Scanner(System.in);  | ||||||
|  |  // Read in the two points  | ||||||
|  |  System.out.print ("Enter the coordinates of the first point " +  | ||||||
|  |  "(put a space between them): ");  | ||||||
|  |  x1 = scan.nextDouble();  | ||||||
|  |  y1 = scan.nextDouble();  | ||||||
|  |  System.out.print ("Enter the coordinates of the second point: ");  | ||||||
|  |  x2 = scan.nextDouble();  | ||||||
|  |  y2 = scan.nextDouble();  | ||||||
|  |  // Compute the distance  | ||||||
|  |  // Print out the answer  | ||||||
|  |  distance = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)); | ||||||
|  |  System.out.println("Distance between them: "+distance);  | ||||||
|  |  }  | ||||||
|  | } | ||||||
							
								
								
									
										
											BIN
										
									
								
								labs/lab3/chapter3_lab-3.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								labs/lab3/chapter3_lab-3.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										0
									
								
								labs/lab3/chapter3_lab-3.pdfZone.Identifier
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								labs/lab3/chapter3_lab-3.pdfZone.Identifier
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										
											BIN
										
									
								
								labs/lab3/die.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								labs/lab3/die.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										13
									
								
								labs/lab3/die.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								labs/lab3/die.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | import java.util.Random; | ||||||
|  |  | ||||||
|  | public class die { | ||||||
|  |     public static void main(String args[]) { | ||||||
|  |         Random rand = new Random(); | ||||||
|  |         int die1 = rand.nextInt(6) + 1; | ||||||
|  |         int die2 = rand.nextInt(6) + 1; | ||||||
|  |  | ||||||
|  |         System.out.println("Dice 1: "+die1+" Dice 2: "+die2+" Sum of two dice: "+(die2+die1)); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user