I am trying to print alphabets from A to F using <c:forEach>
<c:set var="ctr" value="${optListSize}"></c:set> //optListSize is the size of an arraylist
<c:forEach begin="65" end="${ctr}" varStatus="loop" step="1">
<c:out value="<%=String.fromCharCode(64+${ctr})%>"></c:out>
</c:forEach>
I tried the above code but it gives an error. How to go about printing A, B, C, D... incrementally
I am using the following regex - [a-zA-Z0-9]{9,18} which means I can use alphabets and numbers with minimum length as 9 and maximum length as 18.It should not take special characters.
It takes values like ADV0098890 etc. but it is also taking ADV0098890[] which is wrong.
Basically the class is supposed to have a static variable that keeps track of the number of companies (numberOfCompanies) that have been created and a static method that returns the value of this variable. I need to have a constructor and a method to addEmployee, a method to printCompany, and a toString method. The addEmployee method will check that there is only 1 salesperson, 2 designers, and 4 manufacturing persons at a time and will check that there are no more than 7 employees of the company.
The addEmployee method will return a String indicating what the error is (i.e. "There is already a sales person in this company") or a null if the employee was added. If attempting to name a third company, an error message will be shown. what i have so far but my print company mmethod returns null company class :in which i am obliged to use inputdialog because it says that it cannot return void when i use the showmeassage diaolog.
company class:
import java.util.ArrayList; import javax.swing.JOptionPane; public class Company { private ArrayList<Employees> list ; private static int numberOfCompanies;
[Code] ....
error message when print button is clicked:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent at javax.swing.JOptionPane.createInternalFrame(Unknown Source) at javax.swing.JOptionPane.showInternalOptionDialog(Unknown Source) at javax.swing.JOptionPane.showInternalMessageDialog(Unknown Source)
public static void main() { int i; // counter createDeck(); // this is a function call // Show the cards in the deck System.out.println("The deck is as follows:"); for (i=0 ; i < CARDS_IN_DECK ; i++)
[code]....
It is now printing out the value of myDeck[5] but I need to print out first 5 values.
public class Lab12 { public static int SumRow(int [][] a){ int row, column, sum=0; for (row=0;row<2;row++ ) { sum=0; for (column=0;column<2;column++) { sum=sum+a[row][column];
[Code]...
my output is
The sum of row 1 is: 3 The sum of coloumn 0 is: 5 The sum of coloumn 1 is: 5 The max of row 0 is: 4 The max of row 1 is: 2
i have completed a code in java so that it can read spaces in a line but when i run it if i put Line 1 test test for example it will print : [ 3] spaces in Line1 test test what i want to print is [ 3] spaces in "Line1 test test" so the diferences is at " Is there any possible thing that i can do?
class Main { public static void main( String args[] ) { System.out.print( "#Enter text : " ); String text = BIO.getString(); while ( ! text.equals( "END" ) ) {
Implement a Las Vegas slot machine! The machine works as follows. First, it generates three random integers (use import java.lang.Math.*; then call Math.random()*7 to generate a random number between [a,b)) that are in the range of 0-7. Once the numbers are generated, the following rules are used to determine the prize:
- If all three numbers are equal to 7, you are winning $1,000, - If all three numbers are equal, but not equal to 7, you are winning $500, - If two of the numbers are equal to 7 and the third one is six, you are winning $400, - If two numbers are equal, you are winning $100, - Otherwise you are not winning anything.
And for that I wrote:
import java.lang.Math;
public class Assn1_2150130 { public static void main(String[] args) { // Generate three random signle-digit integar from 0-7. int n1 = (int)(Math.random()*7); int n2 = (int)(Math.random()*7); int n3 = (int)(Math.random()*7);
[code]...
But I just can't figure out a way to print out the "YOU WON NOTHING." independently.If I say that n1!=n2 && n2!=n3 && n3!=n1, and then write another line of println. It gives out the number as well as the "NOTHING".
I can't figure out how to print this string only five times. I tried to use the * operator, but that doesn't work with strings apparently, unles i'm not importing correctly.
import java.lang.String; public class Looparray { public static void main(String args[] { for (String myStr= "Hello there!";;) { System.out.print (myStr); System.out.print(" "); } } }
I'm not getting text in the Pledge.txt file. Do I need to assign the pledge to a String variable?
Java Code:
import java.io.*; import java.util.*; public class ReadMe { public static void main(String[] args) throws IOException{ File file = new File("Pledge.txt"); PrintWriter output = new PrintWriter(file);
On line 45 i am trying to add "-" symbol to my output phone number. As of now the out prints like "1800*45*3569377. I want it to print 1800-3569377, or even more ideal: 1-800-356-9377. When printing normally (system.out.println) I can print symbols, but when I try to print from a for-loop it says "unclosed character literal." import java.util.Scanner;
public class Phone_010473030 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a phone number string: "); String Phone_num = input.nextLine(); Phone_num = Phone_num.toUpperCase();
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Hmwk1 { public static void main(String[] args) { String fileName = "lotto.txt"; final int arraySize = 45; int[] count = new int[arraySize];
[Code] .....
My problem is where do I start or add the following code to be added?
I only want to use 1 array and may be or should I try a catch block? The number or numbers that were picked least frequently.
The average number of times that all of the numbers were picked. For example, the average might have been 210 times.
The number or numbers that were picked the average number of times.
The number or numbers that were picked most frequently.
I want to build a class that takes a JTable and previews on screen how it will be printed on the default printer. This is what we use to call as "Print Preview", just like MS Word, Excel, etc.
As we already know Java does not support this functionality out-of-the-box.
Based on some examples I've found googling I built two classes. The first one TestPreview.java justs shows the JTable and the second one PrintPreview.java previews how the JTable will be printed on the printer.
I have two buttons to go through the pages, "PREV" and "NEXT" and "Print' button to print the JTable. My problem is that when my JTable has too many rows and spans in more than one page PrintPreview does not work. It shows the same page again and again. Also, it does not show the entire JTable data, but only some of them and I can't figure out why.
Am having trouble understanding how to print my results (I have 50 of them) , only 10 per line.
Im using an array that is 1-50. The first 25 I raise to the power of 2 and print it.
The next 25, I multiple by 3 and print it
Public class KDowling { /** * @param args the command line arguments */ public static void main(String[] args) { double [] alpha = new double[50]; //declare an array 50 indexes int num=1; // declare variable num int counter=1;
This code is supposed to convert a decimal base number to base 2, 8 or 16. It prints the number but it's supposed to be in the reverse order for example when converting 188 to base 16. it prints CB instead of BC.
package test; import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter a positive integer."); int number = input.nextInt();
So if I wanted to tell the user that the fifth letter they entered is "____" how would I do that.
I am prompting the user to enter a word and then displaying the length of the String. Now I want to display to the user what the fifth letter of the String they entered is.
import java.util.Scanner; public class StringPractice { public static void main(String [] args) { Scanner input = new Scanner(System.in); String word; int lenght;