Write a program to calculate the cost of books based on the number of books.
import java.util.;
public class BOOKcost {
int c=0,cost=0,total=0;
void input()
{
Scanner sc = new Scanner(System.in);
System.out.println("ENTER THE NUMBER OF BOOKS : ");
c=sc.nextInt();
System.out.println("ENTER THE NAMES OF THE BOOK : ");
String book[]=new String[c];
for(int i=0;i<c;i++)
{
book[i]=sc.next();
}
}
void calculate()
{
cost = c300;
if(c>4)
total=cost - ((c-2)*70);
else
total=cost;
}
void display()
{
System.out.println("TOTAL COST : " + total);
}
public static void main(String[]args)
{
BOOKcost ob = new BOOKcost();
ob.input();
ob.calculate();
ob.display();
}
}