Print the shape by getting sides and angle [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Get four length from the user and also get one internal angle.Using that print what shape is that? I tried this.
Scanner in =new Scanner(System.in);
int l1=in.nextInt();
int l2=in.nextInt();
int l3=in.nextInt();
int l4=in.nextInt();
int L=l1;
int angle=in.nextInt();
if((l1==L)&&(l2==L)&&(l3==L)&&(l4==L))
{
if(angle==90)
System.out.println("SQUARE");
}
I do this for SQUARE check.Now i want to find for IRREGULAR QUADRILATERAL.How can i check for this shape?

Related

Can you create a code in array form with this? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Write a Java program that keeps a number from the user and generates an integer between 1
and 7 and displays the name of the weekday.
Create a Strint array with all weekdays ({"Sunday", "Monday"...}) and than get the name by index like this:
int day = 2;
System.out.println(weekdays[day - 1]);//output Monday

How do I add an integer to every element of an array [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm doing a method called adversary that takes two parameters: an array of ints and a number int and it adds that number to each element of the array
Try this
public static void add(int[] a, int n ) {
for (int i=0; i<a.length;i++){
a[i]=a[i]+n;
}}
Let me know if it helps

I want to convert the string to float [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to convert GBP 29.15* to just 29.15.
Can anyone please help?
I have already tried parsing to integer/float, substring etc. but getting an error.
Try this:
float f = Float.valueOf("GBP 29.15*".replaceAll("[^\\d.]+|\\.(?!\\d)", ""));
It removes all non-number characters and then finds the float value.
See also: How to get float value from string

How to print a number with commas as thousands separators in Java..And I also want to print just 2 number after the point [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to print this integer 12345679 like 1,234,68. I was trying to do like this.
System.out.println(count+" "+"$"+fm.format(NumberFormat.getNumberInstance(Locale.US).format(avg)));
How can I do this in java??
NumberFormat currencyInstance = NumberFormat.getCurrencyInstance(Locale.US);
currencyInstance.setMaximumFractionDigits(0);
System.out.println(currencyInstance.format(12345679));
Output: $12,345,679

Why this declaration line does not give any error [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
int [ ] a;
What is happening in this line can anybody describe. It has spaces between [].
You are defining a reference to an array which is presently null, and therefore of undefined size.
This is correct syntax. The spaces in between square brackets are not relevant.
Here is some proper further usage:
int [] a = new int[10];

Categories