+ 1
Please fix this error
classname Actor{ public static void main(String[] args) { name, nationality; gender; age; public: Human(): name("Christopher Hemsworth"), nationality("Australian"), gender('M'), age(38){} void display(){"Name;Nationality;Gender;Age; } } Human person; person.display(); return 0; } { public static void main(String[] args) { System.out.println("name:+"name); } }
24 Answers
+ 1
//class named 'actor of a movie' which has the attributes of name, age, nationality, gender
class Actor_Of_a_Movie
{
String name, nationality, gender;
int age;
}
//you may take it name as ' Actor ' or 'ActorOfAMovie'..
+ 1
Thank you so much
+ 1
For the Time frame
+ 1
import java.util.Scanner;
public class TimeFrame {
public static void main(String[] args) {
int hours = 0;
Scanner input = new Scanner(System.in);
//only one Scanner object works for entire program
System.out.println("2 hours: ");
hours = input.nextInt();
//after taking input display value otherwise no use
System.out.println(hours);
int minutes = 0;
//Scanner input1 = new Scanner(System.in);
//System.out.println("30 minutes: ");
minutes = input.nextInt();
int seconds = 0;
//Scanner input2 = new Scanner(System.in);
//System.out.println("40 seconds: ");
seconds = input.nextInt();
System.out.println("minutes : "+ minutes);
System.out.println("seconds : "+seconds);
}
}
+ 1
Brother I have acode in java
+ 1
I want any one to idet it
0
//Mirasol Sontousidad Pls try as specified in comments...
class Actor{
String name; //name of type String declaration
//nationality, gender, age;
//you can do same for above remaining
Actor(){
//constructor assigning value to name like:
name = "Christopher Hemsworth";
// similarly do for : nationality("Australian"), gender('M'), age(38)
}
public void display() {
System.out.println("name: "+ name);
//you can add remianing similar to above
}
public static void main(String[] args) {
Actor person = new Actor(); //object creation in java for class Actor
person.display(); //calling display method
}
}
//just add remaining in same manner, and see output. hope it helps to complete it.. You just need to add other data in same way as I did it for data filed 'name'
//you can ask here instead of duplicating for any issue..
0
The problem is design a class named 'actor of a movie' which has the attributes of name, age, nationality, gender ,
0
class Actor{
String name;
nationality, gender, age;
Actor(){
name = "Christopher Hemsworth";
nationality="Australian";
gender="Male";
age="38";
}
public void display() {
System.out.println("name:nationality:gender:age : "+ name);
}
public static void main(String[] args) {
Actor person = new Actor();
person.display();
}
}
0
1 error
0
You are not specified the types for nationality, gender, age;
Mirasol Sontousidad so take it as
String nationality;
String gender;
int age;
//you are taking it as string age="38"; so intialize as String age;
//similar types can be as
//String name, nationality, gender, age;
0
I get it but the output is not complete
0
public void display() {
System.out.println(" name = " + name) ;
System.out.println("nationality= "+ nationality);
System.out.println(" Gender: " + gender);
System.out.println("Age = " + age);
}
/*
for your simplicity written in saparate lines and here ex:
System.out.println("Age = " + age);
Your text is "Age =" + and age is a variable..
is equalent to
cout<<"Age="<<age<<endl;
of c++; Mirasol Sontousidad
*/
0
There's no output
0
I posted updated display method, replace it with old..
Post owl code..
0
Yeah but no output
0
class Actor{
String name,nationality, gender,age;
Actor(){
name = "Christopher Hemsworth";
nationality="Australian";
gender="Male";
age="38";
}
/*
public void display()
{
System.out.println(" name = " + name) ;
System.out.println("nationality= "+ nationality);
System.out.println(" Gender= " + gender);
System.out.println("Age = " + age);
//or in just one line : Mirasol Sontousidad (don't confuse. .
/*
System.out.println("Name:"+name +"\n"+
"Nationality : "+ nationality +"\n"+
"Gender: " + gender+ "\n"+
"Age : "+ age );
*/
}
public static void main(String[] args) {
Actor person = new Actor();
person.display();
}
}
0
You're welcome..
0
import java.util.Scanner;
public class Time Frame {
public static void main(String[] args) {
int hours = 0;
Scanner input = new Scanner(System.in);
System.out.println("2 hours: ");
hours = input.nextInt();
int minuetes = 0;
Scanner input1 = new Scanner(System.in);
System.out.println("30 minutes: ");
minutes = input.nextInt();
int seconds = 0;
Scanner input2 = new Scanner(System.in);
System.out.println("40 seconds: ");
seconds = input.nextInt();
}
}
Is it correct?