Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- /**
- * Problem: The third side of the triangle is 8 less than twice the sum of
- * the two other sides and the first side is 5 more than the thrice the
- * second side. If the perimeter is given, how long are its sides?
- * Input: float perimeter
- * Output: float sides
- * perimeter = 3 * second_side + 5 + second_side + 2 * (3 * second_side + 5) - 8
- * perimeter = 10 * second_side + 7
- * first_side = (3 * second_side) + 5
- * second_side = (perimeter - 7) / 10
- * third_side = 2 * (first_side + second_side) - 8
- * third_side = 2 * (3 * second_side + 5 * second_side) - 8
- *
- * @author Carl Nicolas Mendoza, Kurt Charles Gonzaga
- * @version 05/11/2022
- */
- public class Assignment_1
- {
- /**
- * Main method of the application
- *
- * @param arg list of running arguments
- * @return
- */
- public static void main( String[]args)
- {
- float perimeter = 0, first_side = 0, second_side = 0, third_side = 0;
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- try
- {
- System.out.print("What is the perimeter value: ");
- perimeter = Float.parseFloat(br.readLine());
- second_side = (perimeter - 7) / 12;
- first_side = 3 * (second_side) + 5;
- third_side = 2 * (3 * second_side + 5 + second_side) - 8;
- System.out.println("First Side: " + first_side);
- System.out.println("Second Side: " + second_side);
- System.out.println("Third Side: " + third_side);
- }
- catch(IOException ex){}
- }
- }
Add Comment
Please, Sign In to add comment