Introduction to Bluej
Wednesday, November 30, 2022 7:57 PM
double d = Math.pow(625, 1/2) + Math.sqrt(144);
d
13.0 (double)
System.out.print("\nSize of x: "+Integer.SIZE);
New Section 1 Page 1
double y = Math.sqrt(24-25);
y
NaN (double)
double m = y + 10;
m
NaN (double)
import java.util.*;
/**
* Write a description of class LongestWord here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class LongestWord
{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int i, indx;
String sent, word, maxword="";
System.out.print("\fEnter sentence : ");
sent = sc.nextLine().trim() + " ";
for(i = 0; i < sent.length(); i = indx+1){
indx = sent.indexOf(" ", i);
word = sent.substring(i, indx);
if(word.length() > maxword.length()){
maxword = word;
}
}
System.out.print("\nLongest word : " + maxword +
"\nAnd its length is : "+maxword.length());
}
}
New Section 1 Page 2
New Section 1 Page 3