Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Pg 305 Number 2
- *
- * Zain Arfi
- * @version (a version number or a date)
- */
- public class Pg305_2
- {
- public static void main(String [] args)
- {
- String x = "hello";
- int y = 3;
- Count(x,y);
- }
- public static void Count( String x, int y)
- {
- for(int i = 1; i <= y; i++)
- {
- System.out.print(x);
- }
- }
- }
- Pg 305 Number 4
- import java.util.*;
- public class Pg305_4
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- System.out.println("What is the number of the month?");
- int x = console.nextInt();
- Days(x);
- }
- public static void Days(int x)
- {
- if(x == 1)
- {
- System.out.println("31");
- }
- else if(x == 2)
- {
- System.out.println("28");
- }
- else if(x == 3)
- {
- System.out.println("31");
- }
- else if(x == 4)
- {
- System.out.println("30");
- }
- else if(x == 5)
- {
- System.out.println("31");
- }
- else if(x == 6)
- {
- System.out.println("30");
- }
- else if(x == 7)
- {
- System.out.println("31");
- }
- else if(x == 8)
- {
- System.out.println("31");
- }
- else if(x == 9)
- {
- System.out.println("30");
- }
- else if(x == 10)
- {
- System.out.println("31");
- }
- else if(x == 11)
- {
- System.out.println("30");
- }
- else if(x == 12)
- {
- System.out.println("31");
- }
- }
- }
- Pg 306 Number 6
- /**
- * Pg 306 # 6
- *
- * Zain Arfi
- * @version (a version number or a date)
- */
- public class Pg306_6
- {
- public static void printRange(int x, int y)
- {
- for(int number = x; number <= y; number++)
- {
- System.out.println(x);
- }
- }
- }
- /**
- * Pg 307 Number 10
- *
- * Zain Arfi
- * @version (a version number or a date)
- */
- public class Pg306_10
- {
- public static void printGPA(int a, int b, int c, int d)
- {
- int e = (a+b+c+d)/4;
- System.out.println("Maria's grade is" + e);
- }
- }
- /**
- * Pg 307 Number 12
- *
- * Zain Arf
- * @version (a version number or a date)
- */
- public class Pg306_12
- {
- public static void printTriType(int a, int b, int c)
- {
- if(a == b)
- {
- System.out.println("isoceles");
- }
- else if(b == c)
- {
- System.out.println("isoceles");
- }
- else if(a == b && b == c)
- {
- System.out.println("equilateral");
- }
- else
- {
- System.out.println("scalene");
- }
- }
- }
- /**
- * Pg 308 Number 16
- *
- * Z@in @rfi
- * @version (a version number or a date)
- */
- public class Pg308_16
- {
- public static void printPalindrome(String a)
- {
- for(int i=0; i <= a.length(a) + 1; i++)
- {
- if(a.charAt(i) == a.charAt(a.length(a)-i))
- {
- System.out.println("This is a palindrome!!");
- }
- else
- {
- System.out.println("This is not a palindrome!!");
- }
- }
- }
- }
- Pg 308 Number 20
- public class Pg308_20
- {
- public static void numUnique(int x, int y, int z)
- {
- if (x != y && x!=z && y != z)
- {
- System.out.println("3");
- }
- else if( x == y && y != z && x != z)
- {
- System.out.println("2");
- }
- else if(x == z && x != y && y != z)
- {
- System.out.println("2");
- }
- else if(y == z && x != z && y != x)
- {
- System.out.println("2");
- }
- else if (y == z && z == x && y == x)
- {
- System.out.println("0");
- }
- else
- {
- System.out.println("1");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement