



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




package parach1; import java.util.Scanner; public class Parach1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter three edges of the triangle: " ); int edge1 = input.nextInt(); int edge2 = input.nextInt(); int edge3 = input.nextInt(); if((edge1+edge2)>edge3 && (edge1+edge3)>edge2 && (edge2+edge3)>edge1){ int perimeter = edge1 + edge2 + edge3; System.out.println("The perimeter is " + perimeter); } else System.out.println("Invalid Input"); } }
Invalid Output:
package parach1; import java.util.Scanner; public class Parach1 { public static void main(String[] args) {Scanner input = new Scanner(System.in); System.out.print("Enter tuition fee: "); double fees = input.nextDouble(); System.out.print("Enter the percentage increase per year: "); double increase = input.nextDouble(); double fee10 = 0; double totalFee = 0; int i=0; while(i<=14){ fees+= fees*(increase/100); if(i==10){ fee10 = fees; } else if(i>10){ totalFee+= fee10;
int i=1; while (i <= num) { System.out.print("Enter name of student " + i + ": "); n = input.next(); System.out.print("Enter score of student " + i + ": "); sc = input.nextDouble(); if (i == 1) { name1 = n; score1 = sc; } else if (i == 2 && sc < score1) { name2 = n; score2 = sc; } else if (i == 2 && sc > score1) { name2 = name1; score2 = score1; name1 = n; score1 = sc; } else if (i > 2 && sc > score1) { name2 = name1; score2 = score1; name1 = n; score1 = sc; } else if (i > 2 && sc > score2 && sc < score1) { name2 = n; score2 = sc; } i++;
System.out.println("FIRST: " + name1 + " SCORE: "