Course Solutions Uncategorized (Solved) : Easy Java Code Error Cant Figure Write Sentences Code Doesn T Compile Correctly Import Jav Q26401789 . . . .

(Solved) : Easy Java Code Error Cant Figure Write Sentences Code Doesn T Compile Correctly Import Jav Q26401789 . . . .

 

Easy Java Code error I cant figure out

When I write sentences my code doesn’t compile correctly.

import java.util.Scanner;

import java.util.Vector;

public class UserInput{

public static void main(String []args){

Task t=new Task();

int choice=1;

Scanner s = new Scanner(System.in);

while(choice!=5)

{

System.out.println(“1.Add Task”);

System.out.println(“2.Get Size”);

System.out.println(“3.Get All Task”);

System.out.println(“4.Delete Task”);

System.out.println(“5.Exit”);

  

choice=s.nextInt();

  

if(choice==1)

{

System.out.println(“Enter task to add”);

String new_task=s.next();

t.addTask(new_task);

System.out.println(“Task added Successfully”);

}

else if(choice==2)

{

System.out.println(“Size is “+ t.getSize());

}

else if(choice==3)

{

Vector<String> temp=t.getTask();

System.out.println(“Task are as follows”);

for(int i=0;i<temp.size();i++)

System.out.println(temp.elementAt(i));

}

else if(choice==4)

{

System.out.println(“Enter position of task to delete”);

String del_task=s.next();

t.deleteTask(del_task);

System.out.println(“Task Deleted Successfully”);

}

}

}

}

—————————————–

import java.util.Vector;
import java.util.Scanner;

class Task{
Vector<String> tasks;
  
Task()
{
this.tasks=new Vector<String>();
}
public int addTask(String s)
{
if(this.tasks.add(s))
return 1;
else
return 0;
}
public int getSize()
{
return this.tasks.size();
}
public Vector<String> getTask()
{
return this.tasks;
}
public int deleteTask(String s)
{
if(this.tasks.remove(s))
return 1;
else
return 0;
}
  
}

—————————————————–

Error

1.Add Task

2.Get Size

3.Get All Task

4.Delete Task

5.Exit

2

Size is 0

1.Add Task

2.Get Size

3.Get All Task

4.Delete Task

5.Exit

1

Enter task to add

I am walking my

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post