NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import java.util.Scanner;
public class Triangle {

Scanner h = new Scanner(System.in);

private double a, b, c; //sides
private int A, B, C; //angles

public void prompt() {

String[] numS, numA; //Holds User input
boolean pass = true;

while (pass == true) { //Prompts the user to choose a side(s), that they wish to change
System.out.println("Enter the sides you would like to alter (Seperate with a '-'): ");
numS = h.nextLine().split("-");
System.out.println("Your value of "+numS[0]+" was changed to ");
numS[0] = numS[0].toLowerCase();
System.out.println(numS[0]+" because sides cannot have a capital variable");

pass = false;

if (numS[0].matches("[A-Za-z]{1}")) {
System.out.println("Valid");
}
else {
pass = true;
System.out.println("invalid");
}


if (numS.length>3) { //Checks for Error: If user enters more than 3 sides
System.out.println("Invalid Input. A triangle only has 3 sides.");
pass = true;

}



if (pass == false) { //Prompts for the value for the sides chosen
boolean k= true;

while (k==true) {
for (int g=0; g<numS.length; g++) {
boolean z =true;
while (z ==true){

System.out.println("Enter the value of Side '"+numS[g]+"' :");

if (numS[g].equals(numS[0])){
a = h.nextDouble();
z = false;
k= false;
if (a<1) { //Checks for error: If the user enters ZERO or a negative #
z = true;
System.out.println("Invalid Input. Please enter a positive number");
}

}
else if (numS[g].equals("b")) {
b = h.nextDouble();
z = false;
if (b<1) { //Checks for error: If the user enters ZERO or a negative #
z = true;
System.out.println("Invalid Input. Please enter a positive number");
}
}
else if (numS[g].equals("c")) {
c = h.nextDouble();
z = false;
if (c<1) { //Checks for error: If the user enters ZERO or a negative #
z = true;
System.out.println("Invalid Input. Please enter a positive number");

}
}
System.out.println(a);
System.out.println(z);
}
}

if (numS.length ==3) {
if (a+b < c) {
k = true;
System.out.println("Invalid Input. Sum of any two sides, must be larger than the third side");

}
else if (b+c<a) {
k = true;
System.out.println("Invalid Input. Sum of any two sides, must be larger than the third side");
}
else if (a+c<b) {
k = true;
System.out.println("Invalid Input. Sum of any two sides, must be larger than the third side");
}
else {
k = false;

}
}



}
}


}

pass = true;

while (pass == true) {
System.out.println("Enter the Angles you would like to alter (Seperate with a '-'): ");
numA = h.next().split("-");
numA[0]= numA[0].toLowerCase();
pass = false;

if (numA.length>3) {
System.out.println("Invalid Input. A triangle only has 3 Angles.");
pass = true;

}

if (pass == false) {
for (int a=0; a<numA.length; a++) {
if (numA[a].equals("a")){
System.out.println("Invalid input: One of your values was a Side. Please only Enter Angles");
a= 50;
pass = true;
}
else if (numA[a].equals("b")){
System.out.println("Invalid input: One of your values was a Side. Please only Enter Angles");
a= 50;
pass = true;
}
else if (numA[a].equals("c")){
System.out.println("Invalid input: One of your values was a Side. Please only Enter sides");
a= 50;
pass = true;
}
}
}

if (pass == false) {

for (int g=0; g<numA.length; g++) {
boolean z = true;
while (z==true) {
System.out.println("Enter the value of Angle '"+numA[g]+"' :");

if (numA[g].equals("A")) {
A = h.nextInt();
z= false;
if (A < 1) {
System.out.println("Invalid Input. Please enter a positive number");
z = true;
}
}
else if (numA[g].equals("B")) {
B = h.nextInt();
z = false;
if (B<1) {
System.out.println("Invalid Input. Please enter a positive number");
z = true;
}

}
else if (numA[g].equals("C")) {
C = h.nextInt();
z= false;
if (C<1) {
System.out.println("Invalid Input. Please enter a positive number");
z = true;
}
}
}
}

}
}

}

public void print() {
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(A);
System.out.println(B);
System.out.println(C);

}


}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.