how to print the following pattern in java BLUEJ
BLUE
BLU
BL
B
Answers
Answered by
0
Scanner doesn't work in Blue J (java)
bluej
So I have to create matrix of a certain size specified from the user. To do this I was using a Scanner and was going to take two int values, and use those to create the matrix. Long story short, when I ran it, it opened up the terminal window and said "Enter number: " just like I programmed it to, but it wouldn't let me enter a number. I investigated by making a simple program that should take in an integer and output that number, and the results were the same. Any suggestions?
import java.util.*;
public class scanner
{
public void scanner()
{
Scanner a = new Scanner(System.in);
System.out.println("Enter number: ");
int number = a.nextInt();
a.close();
System.out.print(number);
}
}
Answered by
1
class test
{
public static void main (String[] args)
{
String s ="BLUEJ";
int l=s.length();
int a;
for (a=l; a>=1; a--)
{
System.out.println(s.substring(0,a));
}
}
}
Similar questions