//System.out.print("ID"+i+"=");
id[i] = in.nextInt();
year[i] = in.nextInt();
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(year[i]>year[j])
{
temp = year[i];
year[i] = year[j];
year[j] = temp;
temp = id[i];
id[i] = id[j];
id[j] = temp;
}
for(i=0;i<3;i++)
System.out.println("ID: "+id[i]+" ("+year[i]+")");
import java.util.Scanner;
public class syukriah
{
public static void main (String args[])
{
String text;
int countA=0,countI=0,countU=0,i,length;
Scanner in=new Scanner(System.in);
text=in.nextLine();
length=text.length();
for(i=0;i<length;i++)
{
if(text.charAt(i)=='A')
countA++;
else if (text.charAt(i)=='I')
countI++;
else if(text.charAt(i)=='U')
countU++;
}
System.out.println("A="+countA);
System.out.println("I="+countI);
System.out.println("U="+countU);
}
import java.util.Scanner;
public class syukriah
{
public static void main (String args[])
{
int count;
int number[] = new int[10];
int i,j;
count = in.nextInt();
for (i=1; i<=count; i++)
number[i] = in.nextInt();
}
{
}
[Question - Tatasusunan]
Write a program that will receive numbers and output the biggest number
followed by all the numbers that have been entered. The first input will
determine how many numbers to be entered and sum.
Sample Input:
4
20
23
30
2
Sample Output:
BIGGEST:30
20
23
30
2
import java.util.Scanner;
public class syukriah
{
public static void main (String args[])
{
int bil,i,j;
int biggest=-32767;
int num[] = new int[10];
}
}
System.out.println("BIGGEST:"+biggest);
for (j=1; j<=bil; j++)
System.out.println(num[j]);
[Notes]Refer to lab activity, on print string in reverse. Use charAt() and string
length looping.
import java.util.Scanner;
public class syukriah
{
public static void main (String args[])
{
String text;
int i,length;
Scanner in=new Scanner(System.in);
text=in.nextLine();
length=text.length();
}
}
for(i=0;i<length;i++)
{
if(i!=1)
text=text.replace(text.charAt(i),'*');
}
System.out.println(text);
import java.util.Scanner;
public class syukriah
{
public static void main (String args[])
{
String text;
int i,length,count1=0,count2=0;
char letter1,letter2;
Scanner in=new Scanner(System.in);
//System.out.println("Enter the sentence =");
text=in.nextLine();
//System.out.print("First Letter=");
letter1=in.next().charAt(0);
//System.out.print("Second Letter=");
letter2=in.next().charAt(0);
length=text.length();
for(i=0;i<length;i++)
{
if(text.charAt(i)==letter1)
count1++;
if(text.charAt(i)==letter2)
count2++;
}
System.out.println(letter1+" = "+count1);
System.out.println(letter2+" = "+count2);
import java.util.Scanner;
public class syukriah
{
public static void main (String args[])
{
String FirstName;
String LastName;
Scanner in = new Scanner(System.in);
//System.out.println("Your First Name= ");
FirstName = in.next();
//System.out.println("Your Last Name= ");
LastName = in.next();
}
}