+ 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); } }

29th Nov 2021, 5:03 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
24 Respuestas
+ 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'..
29th Nov 2021, 5:33 PM
Jayakrishna 🇮🇳
+ 1
Thank you so much
29th Nov 2021, 6:18 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
+ 1
For the Time frame
29th Nov 2021, 6:21 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
+ 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); } }
29th Nov 2021, 6:34 PM
Jayakrishna 🇮🇳
+ 1
Brother I have acode in java
30th Nov 2021, 11:52 AM
Ammar ALfalahi
+ 1
I want any one to idet it
30th Nov 2021, 11:52 AM
Ammar ALfalahi
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..
29th Nov 2021, 5:22 PM
Jayakrishna 🇮🇳
0
The problem is design a class named 'actor of a movie' which has the attributes of name, age, nationality, gender ,
29th Nov 2021, 5:24 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
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(); } }
29th Nov 2021, 5:35 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
0
1 error
29th Nov 2021, 5:35 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
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;
29th Nov 2021, 5:42 PM
Jayakrishna 🇮🇳
0
I get it but the output is not complete
29th Nov 2021, 5:52 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
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 */
29th Nov 2021, 6:01 PM
Jayakrishna 🇮🇳
0
There's no output
29th Nov 2021, 6:05 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
0
I posted updated display method, replace it with old.. Post owl code..
29th Nov 2021, 6:07 PM
Jayakrishna 🇮🇳
0
Yeah but no output
29th Nov 2021, 6:07 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
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(); } }
29th Nov 2021, 6:12 PM
Jayakrishna 🇮🇳
0
You're welcome..
29th Nov 2021, 6:20 PM
Jayakrishna 🇮🇳
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?
29th Nov 2021, 6:22 PM
Mirasol Sontousidad
Mirasol Sontousidad - avatar