0% found this document useful (0 votes)
70 views1 page

Source Code

This Java code defines a class called LabExer1A that contains a method to set and get a favorite cartoon character. The main method prompts the user to input a favorite number, cartoon character, and initial. It then outputs the favorite number, retrieved cartoon character, and constructs a nickname from initial and array.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views1 page

Source Code

This Java code defines a class called LabExer1A that contains a method to set and get a favorite cartoon character. The main method prompts the user to input a favorite number, cartoon character, and initial. It then outputs the favorite number, retrieved cartoon character, and constructs a nickname from initial and array.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

*;
class LabExer1A{

private String faveCart;


// - Cartoon Character
public void setCart(String cartoon){
faveCart = cartoon;
}
public String getCart(){
return faveCart;
}

public static void main(String args[]) {

LabExer1A lab = new LabExer1A();

Scanner s = new Scanner(System.in);


int faveNumber;
char mi;

System.out.println("\n- - - out put - - -\n"+"Enter favourite number : ");


faveNumber = s.nextInt();

// - Cartoon Char static method


System.out.println("Enter favourite cartoon character : ");
String artoon = s.next();
lab.setCart(artoon);
//

System.out.println("Enter middle initial : ");


mi = s.next().charAt(0);

System.out.println("\n- - - out put - - -\n"+faveNumber + " is my favourite number ");

System.out.println("I Love " + lab.getCart() );

char[] nickNameArray = {'B','A','N'};


System.out.print("My name is Joebanezair "+mi+" Buatona and you can call me ");
for(int i = 0; i < nickNameArray.length; i++)
{ System.out.print(nickNameArray[i]); }
System.out.println("\n \n");

}
}

You might also like