Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation error #13

Open
praveen8919 opened this issue Jun 10, 2022 · 3 comments
Open

Evaluation error #13

praveen8919 opened this issue Jun 10, 2022 · 3 comments

Comments

@praveen8919
Copy link

Plz tell me the solution how to solve this error.
IMG_20220610_112051

@welcome
Copy link

welcome bot commented Jun 10, 2022

Thanks for opening your first issue here! Be sure to follow the issue template!

@BigHero032
Copy link

import java.io.;
import java.lang.
;
import java.util.*;
public class Main{
public static void main(String[]args) throws Exception
{
Scanner get=new Scanner(System.in);
System.out.println("Enter no of objects:");
int n=get.nextInt();
Ticket obj[]=new Ticket[n];
System.out.println("Enter the Total no of tickets:");
int tnt=get.nextInt();
int prev=0;
for(int i=0;i<n;i++)
{
System.out.println("Enter the ticketid:");
int tid=get.nextInt();
System.out.println("Enter the price:");
int p=get.nextInt();
tnt=tnt-prev;
obj[i]=new Ticket(tid,p,tnt);
System.out.println("Enter the no of tickets:");
int not=get.nextInt();
System.out.println("Total no of tickets: "+obj[i].getTotalnooftickets());
if(obj[i].getTotalnooftickets()>=not)
{
System.out.println("Total amount:"+obj[i].Calculatetotalamount(not));
prev=prev+not;
System.out.println("Total no of ticket after booking:"+obj[i].getTotalnooftickets());
}
else
System.out.println("Sorry tickets not available.");
}
}
}

public class Ticket {
private int ticketid;
private int price;
private static int totalnooftickets;
Ticket(int a,int b,int c)
{
this.ticketid=a;
this.price=b;
this.totalnooftickets=c;
}
public void setTicketid(int a)
{
this.ticketid=a;
}
public int getTicketid()
{
return ticketid;
}
public void setPrice(int b)
{
this.price=b;
}
public int getPrice()
{
return price;
}
public void setTotalnooftickets(int c)
{
this.totalnooftickets=c;
}
public int getTotalnooftickets()
{
return totalnooftickets;
}
public int Calculatetotalamount(int x)
{
totalnooftickets=totalnooftickets-x;
return price*x;
}
}

This will work

@thesaravanakumar
Copy link
Owner

Thanks for opening an issue. If any answer is wrong, Please submit a pull request if you find any incorrect answers, I'm happy to merge it 👍.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants