Question:: We define a Metropolis to be a city, that is either a capital city with more than 100 000 citizens or more than 200 000 citizens and an average income of 720 000 000 per year.
Give a boolean expression with all three variables that is true if and only if the city is a metropolis.
Code::
import java.util.*;
public class NT
{
public static void main(String [] nt)
{
boolean iscapital=false;
long nofcitizens;
double taxpercitizen;
Scanner in=new Scanner(System.in);
System.out.print("Press Y if City is a Capital Else anything:");
char a=in.next().charAt(0);
if(a=='y'||a=='Y')
{
iscapital=true;
}
System.out.print("Enter Number of Citizens:");
nofcitizens=in.nextLong();
System.out.print("Enter Tax Per Citizen:");
taxpercitizen=in.nextDouble();
if(iscapital && nofcitizens>=100000||nofcitizens>=200000&&taxpercitizen*12*nofcitizens>720000000)
{
System.out.println("Yes This city is a Metropolis");
}
else
{
System.out.println(" This city is not a Metropolis");
}
}
}
Give a boolean expression with all three variables that is true if and only if the city is a metropolis.
Code::
import java.util.*;
public class NT
{
public static void main(String [] nt)
{
boolean iscapital=false;
long nofcitizens;
double taxpercitizen;
Scanner in=new Scanner(System.in);
System.out.print("Press Y if City is a Capital Else anything:");
char a=in.next().charAt(0);
if(a=='y'||a=='Y')
{
iscapital=true;
}
System.out.print("Enter Number of Citizens:");
nofcitizens=in.nextLong();
System.out.print("Enter Tax Per Citizen:");
taxpercitizen=in.nextDouble();
if(iscapital && nofcitizens>=100000||nofcitizens>=200000&&taxpercitizen*12*nofcitizens>720000000)
{
System.out.println("Yes This city is a Metropolis");
}
else
{
System.out.println(" This city is not a Metropolis");
}
}
}
Output::