Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 8.import java.util.*;
- public class Problem8
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- System.out.print("Input a value for a: ");
- double a = console.nextDouble();
- System.out.print("Input a value for b: ");
- double b = console.nextDouble();
- System.out.print("Input a value for c: ");
- double c = console.nextDouble();
- discriminant(a, b, c);
- double xvertex = -(b/(2*a));
- double discr = discriminant(a, b, c)/2*a;
- double x1 = xvertex + discr;
- double x2 = xvertex - discr;
- System.out.println("Your X1 Value is " + x1);
- System.out.println("Your X2 Value is " + x2);
- }
- public static double discriminant(double a, double b, double c)
- {
- return(Math.sqrt(b*b-4*a*c));
- }
- }
- 10.import java.util.*;
- public class problem10
- {
- public static void main(String[] args)
- {
- double area = 0.0;
- System.out.print("Input your radius to calculate your area: ");
- Scanner console = new Scanner(System.in);
- int radius = console.nextInt();
- area = calculation(radius);
- System.out.println("Your area for your circle is: " + area);
- }
- public static double calculation(int radius)
- {
- double area = Math.PI*Math.pow(radius, 2);
- return area;
- }
- }
- 12.import java.util.*;
- public class problem12
- {
- public static void main(String[] args)
- {
- Scanner console=new Scanner(System.in);
- System.out.print("Input your base number");
- double base = console.nextDouble();
- System.out.print("Input your exponet");
- int exponent = console.nextInt();
- double scientific=calculation(base, exponent);
- System.out.println("Your number is:"+ scientific);
- }
- public static double calculation(double base, int exponent)
- {
- double scientific = base*Math.pow(10, exponent);
- return scientific;
- }
- }
- 14.import java.util.*;
- public class problem14
- {
- public static void main(String [] args)
- {
- Scanner pikachu = new Scanner(System.in);
- System.out.print("Input your radius");
- double radius = pikachu.nextDouble();
- System.out.print("Input your height");
- double height= pikachu.nextDouble();
- double surface=cylinderSurfaceArea(radius, height);
- System.out.println("Your surfacearea of the is:"+ surface);
- }
- public static double cylinderSurfaceArea(double radius, double height)
- {
- double surface=2*Math.PI*Math.pow(radius,2)+2*Math.PI*radius*height;
- return surface;
- }
- }
- 16.import java.util.*;
- public class problem16
- {
- public static void main(String [] args)
- {
- Scanner pikachu = new Scanner(System.in);
- System.out.print("Input your first triangle side");
- double side1 = pikachu.nextDouble();
- System.out.print("Input your second triangle side");
- double side2 = pikachu.nextDouble();
- System.out.print("Input your third triangle side");
- double side3 = pikachu.nextDouble();
- if(side1+side2>side3 || side2+side3>side1 || side1+side3>side2)
- {
- double heron=TriangleArea(side1, side2, side3);
- System.out.println("Your triangle area is"+ heron);
- }
- else
- {
- System.out.println("You're Stupid");
- }
- }
- public static double TriangleArea(double side1, double side2, double side3)
- {
- double s= (side1+side2+side3)/2;
- double Heron= Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
- return Heron;
- }
- }
- 18.import java.util.*;
- public class problem18
- {
- public static void main(String [] args)
- {
- Scanner pikachu = new Scanner(System.in);
- System.out.println("Input your phrase");
- String phrase = pikachu.nextLine();
- for(int length = 1; length <= phrase.length(); length++)
- {
- System.out.println(phrase.substring(length-1,length));
- }
- }
- }
- 20.import java.util.*;
- public class Problem20
- {
- public static void main(String[] args)
- {
- Scanner Pikachu = new Scanner(System.in);
- System.out.print("On what day of the month were you born");
- int day = Pikachu.nextInt();
- System.out.print("What is the name of the month in which you were born?");
- String month = Pikachu.next();
- System.out.print("During what year were you born?");
- int year = Pikachu.nextInt();
- System.out.println("You were born on"+ month + day + "," + year + ".You're mighty old");
- }
- }
- 22.import java.util.*;
- public class Problem22
- {
- public static void main(String [] args)
- {
- Scanner pikachu = new Scanner(System.in);
- System.out.print("What is your GPA?");
- double GPA = pikachu.nextDouble();
- System.out.print("What is your SAT score?");
- int SAT = pikachu.nextInt();
- if(GPA>=1.8 || SAT>= 900)
- {
- System.out.println("You have been accepted");
- }
- else
- {
- System.out.println("You have been rejected");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement