tong1 22 Posting Whiz

The area of a circle is 3.14*radius*radius rather than 3.14 *(radius*2)
The following static method start() may do one run to calculate the area of a circle.

private static void start() {
String n = JOptionPane.showInputDialog(null,"Enter the radius to calculate the area of a Circle");
int num = Integer.parseInt(n);
DecimalFormat twoDigit= new DecimalFormat("0.00");
double form1 = 3.14 * (num*num);
JOptionPane.showMessageDialog(null,"The area of the circle is "+ twoDigit.format(form1));
}

extemer, can you clearify your intention: What do you want to do with this program?
1. after one run, you want to finish the program's execution, or
2. after one run, you want to do another run until client clicks the cancel button to stop the execution of this program?

tong1 22 Posting Whiz

StringBuffer has an instance method: reverse() to do the reversing job.

import java.io.*;
import javax.swing.JOptionPane;
 public class Palindrome{   

 static boolean palindromeCouplet (String s)   {
 	StringBuffer s1 = new StringBuffer(s);
 return ((s.compareTo(new String(s1.reverse()))==0) ? true :false)  ;
 	}	

 public static void main(String[] args) {	
 	while(true){
    String str=JOptionPane.showInputDialog( null,  
	"Type in a word!\nPress cancel to ternimate。",
	"IS A PALINROME",
	JOptionPane.QUESTION_MESSAGE);    
    
	if (str == null) {
	System.out.println("Bey for now");
    	break;
    	} 
JOptionPane.showMessageDialog( null,  
	"Palindrome: " + palindromeCouplet(str),
	str + " IS A PALIDROME? ",
	JOptionPane.INFORMATION_MESSAGE);  
          }
      }   
}
tong1 22 Posting Whiz

The story from text book “Java How to program” by H.M.Deitel & P.J.Deitel, 5th ediction, 2003. p.372) .
“Let us motivate the need for static class-wide data with a video game example. Suppose that we have a video game with Martians and other space creatures. Each Martian tends to be brave and willing to attack other space creature when the Martian is aware that there are at least four other Martians present. If fewer than five Martians are present, each Martian becomes cowardly, so each Martian needs to know the martianCount. …“
Accordingly I have written the following java program to demostrate the usage of static and instance variable/method.

class Martian  {
private String 	name; // instance variable
private static int count; // class variable
 
public Martian(String s){ // constructor with one argument: the name of the Martian
   name = s; 
   System.out.println( name + " was created");
   count++;
	};

/* The method cowardly() is defined as static since it descripts the psychosis of the whole class Martian/all Martians
 * Also be noticed that the static method accesses the static variable(count) only */
 
public static void cowardly() { // the method to test whether each individual Marian is cowardly or not.
System.out.println( // if the total number of Martians is less than 5, they are cowardly.
(count < 5 ? "Martians are cowardly." : "Martians aren't cowardly."));
   }

public static int getCount() { return count; }

protected void finalize(){ // A martian died, the memory has been returned …
tong1 22 Posting Whiz

Instance variable/method - Variables/methods that are specific to each instance (object) of the class e.g. name, age.... When accessing/calling them, the object, as the reference has to be used as a handle.
Class variable/method - Variables/methods that represent/deal with class wide situation, e.g. a static variable which belongs to a class and has only one value specific to the class. When accessing/calling them, the class name is needed as a handle.

tong1 22 Posting Whiz

kch1973 , the following comments for your consideration.
1. Since the reference of the array is in fact passed to the sortArray method (i.e. pass by reference), no return value(s) is needed. Therefore the definition of the sorting method would be:
public static void sortArray (Printer[] a){...}
where The argument of the method (which receives the reference of the Printer array) may simple be named as "a" so that the name of the array in the method body is simply called "a". This is only a suggestion to simplify the array name.
2. In the body of the method, the parts 1, 2, 3 should thus be deleted so that the sorting operation is directly made of the array.
3. The comparison for the sorting is made of the names between a pair of adjacent elements. Therefore the "if statement" should be written in the following way:

if ((a[j].getProductName()).compareTo((a[j+1].getProductName()))>0){ //if it is true, swap the two elements
...
}

4. In the main method the sortArray method is thus called by the following code:
sortArray(printerProduct);

5. This is a sorting method called bubble sort. Some improvements can be made for your further reference.

kch1973 , you may find out the code to test the correctness of the sorting.

tong1 22 Posting Whiz

the printf(...) ,which is a C-style output, is used starting from JDK1.5.
for the details about java printf() see
6. 14. 1. Using Java's printf( ) Method

tong1 22 Posting Whiz
tong1 22 Posting Whiz

A further development of extemer's program leads to the following table showing the furture values of one thousand dolloars investment calculated based on compound interest: a(t) = (1 + i)^t where i is rate while t the number of years

import java.text.DecimalFormat;
import javax.swing.*;
import javax.swing.JTextArea.*;

   class TextAreaDemoB {
     public static void main(String[] args){

     double amount,
           p=1000.0,
           rate=.025;

     DecimalFormat pre= new  DecimalFormat("0.00");
     DecimalFormat preRate= new DecimalFormat("0.000");
     JTextArea out= new JTextArea(0,0);

     out.append(" year, rate->\t");
     for (int j=0;j<10;j++)
     out.append(preRate.format(rate+j*0.025)+ "\t");
     out.append("\n");

     for(int year=1; year<=10; year++) {
     	out.append( year + "\t");
     	for (int j=0; j<10; j++){
     amount=p * Math.pow( 1.0 + (rate+j*0.025) , year );
 	 out.append(pre.format( amount )+ "\t" );
 	 }
 	 out.append("\n");
 	 }

    JOptionPane.showMessageDialog(null,out,"Future values of $1000 investment with various numbers of years and rates",JOptionPane.INFORMATION_MESSAGE);
	}
}
tong1 22 Posting Whiz

the problem becomes the method of MouseEvent:
getComponent()
which Returns: the Component object that originated the event, or null if the object is not a Component.
This method cann't identify the actually component clicked.

tong1 22 Posting Whiz

masijade , Thank you for your remind.
I have added code to show the difference between two kinds of interests: simple and accumulated.
I hope gudads will compare the output format between his and mine to make further decision about changes in the code for his output, perhaps also show difference between two kinds of interests if there is.

tong1 22 Posting Whiz

Your code is basically correct. Please use the tag [CODE] for your code.
I have made a small modification. I am not sure if there is a term called "accumulated interests" which is different from simple interests.

import java.lang.*;
public class simple {
public static void main (String[] args){
// this program calculates the simple interest.
int principal, noy;
double rate, si;
principal = 1000;
noy = 3;
rate = 2.5;
si = (principal * noy * rate) /1000;
double d = (Math.pow((1.0 + rate/100), (double)noy) - 1)*100;
System.out.printf (" The principal is %d \n number of years: %d, \nrate is: %f \n The calculated simple interest is:%f\n ", principal,noy,rate,si);
System.out.printf("Accumulated interests: %5.2f\n", d);  // using C_style to define the output of the  double
    }
}

output:
The principal is 1000
number of years: 3,
ate is: 2.500000
The calculated simple interest is:7.500000
Accumulated interests: 7.69

masijade commented: do not simply do other's homework. At the very least [i]explain[/i] the changes. Better, just tell them what to change. They don't learn anything this way. -2
tong1 22 Posting Whiz

I wrote a testing program as follows. If I clicked twice the label is deleted. Perhaps for the line 5:
this.layeredPane.remove(e.getComponent());
your may replace e.getComponent() with actual reference: "label".

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DeleteComponent extends JFrame {	
JLabel label;
public DeleteComponent(){
	Container container = getContentPane();
	label = new JLabel("The label to be deleted");
	container.add(label);
	setVisible(true);
	setSize(150,100);
	container.addMouseListener(new MouseAdapter(){
		public void mouseClicked(MouseEvent e) {	
  		if (e.getClickCount() == 2) {
            remove(label);
            repaint();
        }
    }});
}

public static void main(String args[]){
	DeleteComponent dc = new DeleteComponent();
	dc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
tong1 22 Posting Whiz

should line 65 be:

pieces =new ChessPiece[?][8];

?

tong1 22 Posting Whiz

Following javaAddict's code, I have replaced the BufferedWriter and FileWriter with BufferedReader and FileReader. In order to get each integer value back, the method of class String split is given the delimiter of a space " ". Please read the method of String split(...) in API. Therefore, for reading the existing file I would like to use the following code. Of course, xterradaniel, you have to parse each token into int type.

BufferedReader rd = null;
	try {
   		rd = new BufferedReader(new FileReader("Exercise09_19.txt"));
		String s="";
		
		while( (s=rd.readLine()) != null){
			String ss[]=s.split(" "); // set up the delimiter as space " "
			for (int i=0; i<ss.length;i++)
		    System.out.print(ss[i] + " ");// The string/token array is printed
		}
		
	} catch (Exception e) {
  	System.out.println(e.getMessage());
	} finally {
	  try {if (rd!=null) rd.close();} catch (Exception e) {}
	}
tong1 22 Posting Whiz

The code in line 190 requests an Inventory construtor with 5 arguments. In fact there is no such a constructor with the same signature in the definition of class Inventory.

tong1 22 Posting Whiz

Normally the labels, buttons, and other components are placed in different sub-container from the drawing canvas. Therefore I have further modified the code so that the drawing part is defined as an inner class: Mydraw.
Also the Graphics2D has more function than Graphics, such as setPaint(), texture paint, coordinate transformation(rotation), ann so on. Read API about Graphics2D as well.

import java.awt.*;
import javax.swing.*;
import java.awt.image.*;

public class DrawGraphics extends JFrame {
	private JLabel label1;
	private JLabel label2;
	private JLabel label3;
	
	public DrawGraphics() {
		super("Testing JLabel"); // the title for the window
//setLayout(new BorderLayout()); // the default LayoutManager for JFrame is BorderLayout. Therefore this line of code is deleted.
		JPanel p = new JPanel();
		label1 = new JLabel("Workshop 3: Graphics");
		label1.setFont(new Font("monospaced", Font.BOLD+Font.ITALIC, 18));
		label1.setForeground(Color.blue); // set the Font color
		label1.setBorder(BorderFactory.createRaisedBevelBorder()  ); //set up the label border raised
		p.add(label1);
		p.setBackground(Color.pink);
		add(p,BorderLayout.NORTH);
		add(new Mydraw(),BorderLayout.CENTER);
		}
	class Mydraw extends JPanel{
		
	BufferedImage texture(){  // make a texture unit pattern
	BufferedImage buffImage = new BufferedImage( 10, 10, BufferedImage.TYPE_INT_RGB );  //create a space 10*10 to store buffImage
      Graphics g = buffImage.createGraphics();   // the pencil g for the buffImage
      g.setColor( Color.YELLOW ); // draw in yellow, find a yellow pencil
      g.fillRect( 0, 0, 10, 10 ); // draw a filled rectangle     
      g.setColor( Color.RED );   // draw in red
      g.fillRect( 1, 1, 8, 8 );  // draw a filled slightly smaller rectangle
      return buffImage; 
      }

		public void paint(Graphics g){

			g.setFont(new Font("Arial Black", Font.BOLD, 60)); // set Font
			g.setColor(Color.blue); // set the color of the drawing pencil. …
tong1 22 Posting Whiz

I have modified your code by adding the paint() method to draw string, oval, and rectangle, from which you may start to taste the Graphics methods. Read the API to find more methods of Graphics.

import java.awt.*;
import javax.swing.*;

public class DrawGraphics extends JFrame {
	private JLabel label1;
	private JLabel label2;
	private JLabel label3;
	
	public DrawGraphics() {
		super("Testing JLabel");
		setLayout(new FlowLayout());
		
		label1 = new JLabel("Workshop 3: Graphics");
		label1.setFont(new Font("monospaced", Font.BOLD+Font.ITALIC, 18));
		label1.setForeground(Color.orange);
		add(label1);
		}
		
		public void paint(Graphics g){
			super.paint(g);
			g.setFont(new Font("ARAIL", Font.BOLD, 30)); // set Font
			g.setColor(Color.blue); // set the color of the drawing pencil.
			g.drawString("GWorkshop 3: Graphics", 20,150);// draw a string
			g.setColor(Color.cyan);
			g.fillOval(100,160,100,200); // fill Oval/circle/ellipse
			g.setColor(Color.gray);
			g.fillRect(250,160,100,200); // fill rectangle/squre
		}
	public static void main(String args[]){
		DrawGraphics dg = new DrawGraphics();
		dg.setSize(400,400);
		dg.setVisible(true);
                  dg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	}
tong1 22 Posting Whiz

for (double d : numbers) {
total += d;
}

is equivalent to:

for (int i=0; i<numbers.length;i++){
double d = numbers[i];
total += d;
}
tong1 22 Posting Whiz

line 24,25,26:
You have incoorectly made 5 parameters for the constructor, but in fact the Camera constructor requests 4 arguments:
Camera( String Name, int Number, int Units, double price ) // see line 120

...

According line 30,31: Camera.showInventory();
The showInventory() method must be a static since you use the class name Camera as the handle, but actually the showInventory() is not static.

tong1 22 Posting Whiz

The StringTokenizer in java.util.* may do your job.

tong1 22 Posting Whiz
import java.io.*;
class vowel{
public static void main (String args[])throws IOException{
String sentence;
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader br = new BufferedReader (isr);
sentence = br.readLine();
System.out.println (vowels(sentence)[0]);
System.out.println (vowels(sentence)[1]);
	}
   static Object[] vowels (String default1){ // return an Object array including various data types
	char ch;
	int vowels_position [] = {0,0,0,0,0};
	char vowels_value [] = {'a','e','i','o','u'};
	for (int i=0; i<default1.length(); i++){
	ch=default1.charAt(i);
	switch (ch) {
	case 'a': case 'A':{vowels_position[0]++;break;}
	case 'e': case 'E':{vowels_position[1]++;break;}
	case 'i': case 'I':{vowels_position[2]++;break;}
	case 'o': case 'O':{vowels_position[3]++;break;}
	case 'u': case 'U':{vowels_position[4]++;break;}
	  }
	}
	int count=0;
	for (int k=0; k<vowels_position.length; k++)
	if (vowels_position[k]>vowels_position[count])
	count=k;
	Object o[]=new Object[2]; // only two different types of elements are needed
	o[0]=vowels_value[count];  // char type element
	o[1]=vowels_position[count]; // int type element
	return o; // return the multi-type Object array
  }
}
Xufyan commented: great :) +0
jon.kiparsky commented: Give help, not code. +0
tong1 22 Posting Whiz

First you may try the class : javax.swing.JOptionPane
You should at first

import javax.swing.JOptionPane;

Then you may, for example, replace line 14 and 15 by the following code:

String input = JOptionPane.showInputDialog("To Order new item. Press Y to leave press any other key..");

Try it. Does it work?
Read API about this class (JOptionPane) try to use its other methods to replace your rest DOS input/output .

This is one of the selections from swing. You may use JTextField, JButton, and others as well.

tong1 22 Posting Whiz

I guess, in the Bank's constructor, the attribute "bankAddress" should be:

bankAddress = new Address();

Where is the code for the definition of Bank class?

tong1 22 Posting Whiz

The line 3 and 4:

private string city;
private string state;

The type of both attributes city and state should be String

tong1 22 Posting Whiz

When executing the line of code:
System.out.println(new Final(2));
an address of the instance of the Final is printed as 9cab16 (Final@9cab16)
which tells that the instance of Final is stored at the memory: 9cab16 in hexadecimal system

tong1 22 Posting Whiz

Some error in your code:
line 5 should be System.out.println(...)
line 4 should be float number = r.nextFloat();
If the range of current random is [0,1] then

[B]float[/B]	number = -1 + 2*r.nextFloat();

the random number varies in the range of [-1,1]

tong1 22 Posting Whiz

I mean that in the loop body, one should do the "sum = sum + number_counter;" first.
Otherwise the odd number 1 would be missing, and also the number 101 would be incorrectly included in the sum. In iSax's Algorithm, to do the updating on number_counter first, thus the odd number 1 was missing, and the odd number 101 is also incorrectly included in the sum.

tong1 22 Posting Whiz

Calling String toString() method shows that
the JVM would dynamically identify the objects of cat, Dog, Duck, and Cow since the array stores their references respectively. Therefore neither casting nor the instanceof operator is needed. An Object array may store a reference of any kind of type.

public class Part5{

	public static void main(String[] args) {
		
		Object[] animals=new Object[4];
		animals[0]=new Cat();
		animals[1]=new Dog();
		animals[2]=new Duck();
		animals[3]=new Cow();
		
		for (Object o:animals)
		System.out.println(o);
	}
}


class Cat {
	public String toString(){
		return "Miyau...";
	}
}
class Dog 
{
	public String toString(){
		return "HowHow....";
	}
}
class Duck {
	public String  toString(){
		return "GAAGAa.....";
	}
}
class Cow {
	public String toString(){
		return "Moooooooo......";
	}
}

output:
Miyau...
HowHow....
GAAGAa.....
Moooooooo......

tong1 22 Posting Whiz

Note: order of execution in loop body has been altered.

Use psuedo code to express the algorithm:

• set sum to 0
• set number_counter to 1

• while number counter <= 100 do the following loop:
sum = sum + number_counter
add 2 to the number_counter

• Print sum
• End

tong1 22 Posting Whiz

Normal class:
Normal class has definition of methods and variables and their declaration as well.
Abstract class:
Abstract class has methods and variables with definition and declaration as well like the normal classes. Hoewever it must have at least one method with no implementation, which hence is called abstract method.
We can not make instance of Abstract Class.
Interface:
Interface is an "extreme" abstract class where all the methods are abstract, that is, all methods with no implementation.

Reference:
Normal class vs Abstract class vs Interface class 65

tong1 22 Posting Whiz

Some google search result:

strictfp is a keyword in the Java programming language that restricts floating-point calculations to ensure portability. It was introduced into Java with the Java virtual machine (JVM) version 1.2.
http://en.wikipedia.org/wiki/Strictfp

Frankly, most programmers never need to use strictfp, because it affects only a very small class of problems.

tong1 22 Posting Whiz

Should we modify the formula ?

selection menu :
1.Area of a Circle ----(3.14 * (r*r))
2.Area of a Trapezoid ---- (height * (base1+base2) / 2)
3.Volume of a Sphere ---- ( 3.14 *(radius*radius*radius)/.75)
4.Volume of a Cylinder ---- (3.14 * (radius * radius) * height)

tong1 22 Posting Whiz

how to do the displaying of objects in array program using an interactive console/gui

If the Object array is ObjectArray where the elements are of various types the following traversal loop may be useful.

for (Object o: ObjectArray)
System.ou.ptinrln(o);

If you are going to add/delete an element into/from an Object array you have to create a new Object array object because of the change in the array' attribute: length.

Please provide specification in detail for this assignment, and also the code you have done so far.

Also see the Thread
http://www.daniweb.com/forums/thread307073.html

tong1 22 Posting Whiz

Is the array your teacher asks you to create a type of Object, or a concrete type defined by you, or a primitive data type?
If an object is added, is it added before the first element or after the last element, or somewhere expected?
Please provide certain specification.

tong1 22 Posting Whiz

It happends with Chinese characters as well. I think this is probably due to the computer system (windows' config) where your output is printed.

tong1 22 Posting Whiz

Since the interpunction is not a word shoud we indicate some delimiters as well so that, e.g. "How are you ?" will be made of 3 words instead of 4.

StringTokenizer sT = new StringTokenizer(myString, " ,.!?'\"");
tux4life commented: Good :) +8
tong1 22 Posting Whiz

“An array is a container object that holds a fixed number of values of a single type”. Unfortunately it’s true for some cases only.
http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
I would say: “An array is a container object that holds a fixed number of values either a single type or different types.” In other words, in the Java programming language arrays are objects, are dynamically created, and may be assigned to variables of different types .
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
In present post, one receives input as an String array via main’s argument. The method int [] breakUp(String [] myArray) collects the integer inputs, and the method Object[] process(int a[]) receives an int array and returns the outputs including maximum, minimum, project, and average via an Object array. Therefore, in the main’s body there are two lines of code only:

for (Object n:process(breakUp(args)))
		System.out.println(n);

The usefulness of returning an array by a method is obvious. But why it does not become a common practice/often used in Java?

import java.util.*;

public class Tokenizer1 {

	public static int [] breakUp(String [] myArray){
		int n = myArray.length;
		int a[] = new int[n];
		int counter=0;
		for( int i = 0; i < n; i++ ) {
			try {
			int currentValue = Integer.parseInt(myArray[i]);
			a[counter++] = currentValue;
			}catch(NumberFormatException e){}
		}
		if (counter==n)
		return a;
		if (counter !=0){
			int aa[]= new int[counter];
			for (int i=0; i<counter;i++)
			aa[i]=a[i];
			return aa;
		}
		return null;
		
	}
	
	public static Object[] process(int a[]) {
		int max=a[0];
		int min=a[0];
		int sum=a[0];
		int …
tong1 22 Posting Whiz

Where is your code?

tong1 22 Posting Whiz

Learn from code example

tong1 22 Posting Whiz

Use StringTokenizer in java.util.* to get each word as a token. The delimiters include space character, and other interpunction。

tong1 22 Posting Whiz

Please have a look at the post for your reference. In this project a statistics has been made on the words in a text file.

tong1 22 Posting Whiz

In bubble sort, sorting on the stable region is unnecessary.
As previous post (28 days ago) points out:
after first run of the outerloop, the maximum of the array will be located on the left end (the left most).
after the second run of the outerloop, the next to the maximum will be placed on the second left location.
.....
In this way, these miximum, next to maximum, next ot next to maximum, and so on ... , have become placed in their correct locations in terms of order. They are sorted. Such a partially sorted region is called stable region, as indicated by the red color in a previous post. No more sorting on this region is needed. The "n-i-i" is the upper(left) limit of the scanning(sorting) by the nested loop. Since 'i' increases the upper(left) limit decreases so that the red region wouldn't be re-sorted. Therefore, we have saved the unnecessary sorting on the stable region.

tong1 22 Posting Whiz

Megha SR
Even you have corrected all the errors accordingly you are still unable to run this program.
If you run it, the following error will be printed:
Exception in thread "main" java.lang.NoSuchMethodError: main
You should define a proper main method which requests only one argument: a String array: String args[].
So if you insert the proper main method, for example, as follows, the JVM will interprete it and prints output.

public static void main(String args[]){
	main(2,3,4,5,6);
}
tong1 22 Posting Whiz

See Static class declarations by InfoWord-JavaWord

“You declare a top-level class at the top level as a member of a package. Each top-level class corresponds to its own java file sporting the same name as the class name. A top-level class is by definition already top-level, so there is no point in declaring it static; it is an error to do so. The compiler will detect and report this error.
….. A nested top-level class is a member classes with a static modifier. “

tong1 22 Posting Whiz

An array is a container object that holds a fixed number of values of a single type.” (true for some cases only)
http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
In broad sense, I would say:
“An array is a container object that holds a fixed number of values of either a single type or different types/multi-types.” In other words, in the Java programming language arrays are objects, are dynamically created, and may be assigned to variables of different types .
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
For example, the following code shows that the Object array object contains values of 4 different types: ImageIcon, String, BufferedImage and int.

import javax.swing.*;
import java.awt.image.*;
class Array{  	
  	public static void main(String []args){
    Object object[]=new Object[4];
    object[0]=new ImageIcon("ABC.png");
    object[1]="Image Icon ABC";
    object[2]=new BufferedImage(400,400,BufferedImage.TYPE_3BYTE_BGR);
    object[3]=34;
     }
 }
tong1 22 Posting Whiz

JamesCherrill, thank you for your clear explaination.

tong1 22 Posting Whiz

One may replace peter_budo's code 38-44 with the following c-style code:

System.out.printf("max=%2d", max);
        
        for (String s: adjective)
           for(String n: noun)
           System.out.printf("\n%s as %s",s , n);

I also tried to use this style in initiating the string array noun, e.g.

replace :

for (int i=0; i<cNoun; i++) 
        noun[i] = scan.next();

by

for (String s: noun)
s=scan.next();

which does not work. All the elements remain null after the assignments by loop. It seems that in c_style format, one may not use the elements as left values. I need help to explain this issue.
Attached please find the code I modified

tong1 22 Posting Whiz

source for this information

JamesCherrill, thank you for correcting my answer. I am wrong. But, in Java what is the memory size of boolean data type in bits ?
I have just checked a Text Book "Java How to Program" by Deitel and Deitel. It is said:" The representation of a boolean is specific to the Java Virtual Machine on each computer platform." Can I say:"the memory size for boolean varies on different computer platform"?

tong1 22 Posting Whiz

One byte of menory is requested for storage of a value/variable of boolean data type

tong1 22 Posting Whiz

Katana24 ,
the line 15 should be
} if( array < minimum)

You may consider how to deal with the situation where the input string includes both some digital tokens and some invalid tokens, e.g. "12g3".
How do you collect the valid inputs only ?