0% found this document useful (0 votes)
7 views4 pages

Aspect Ratio and K - Notation Resolution

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Aspect Ratio and K - Notation Resolution

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

public class Graphic {

static int GCD(int a,int b){


int f,g,r;
if(a>b){
f=a;
g=b;
while(g!=0)
{
r=f%g;
f=g;
g=r;
}
return f;
}
else{
f=b;
g=a;
while(g!=0)
{
r=f%g;
f=g;
g=r;
}
return f;
}
}

static void Aspect_ratio(int a, int b){


System.out.println("Aspect ratio of "+a+"*"+b+" is
"+a/GCD(a,b)+":"+b/GCD(a,b)+".");
}

static double err_in_thou(int n, double k){


return ((k*1000/((float)n))-1)*100;
}

static double K_notation(int p){


int count, recount;
count=0;
recount=0;
double i,e,r;
r=9;
i=1;
e=err_in_thou(p,i);
while(e<-r)
{
i=i*2;
e=err_in_thou(p,i);
}
if(e>=-r && e<=r)
{
count=count+1;
return i;
}
else
{
i=1.5;
e=err_in_thou(p,i);
while(e<-r)
{
i=i*2;
e=err_in_thou(p,i);
}
if(e>=-r && e<=r)
{
count=count+1;
return i;
}
else
{
i=2.5;
e=err_in_thou(p,i);
while(e<-r)
{
i=i*2;
e=err_in_thou(p,i);
}
if(e>=-r && e<=r)
{
count=count+1;
return i;
}
else
{
i=3.5;
e=err_in_thou(p,i);
while(e<-r)
{
i=i*2;
e=err_in_thou(p,i);
}
if(e>=-r && e<=r)
{
count=count+1;
return i;
}
else
{
i=4.5;
e=err_in_thou(p,i);
while(e<-r)
{
i=i*2;
e=err_in_thou(p,i);
}
if(e>=-r && e<=r)
{
count=count+1;
return i;
}
else
{
return -1;
}
}
}
}
}
}
static void K_notation_resolution(int a, int b){
if(a==b){
double j=K_notation(a);
if(j>=1){
System.out.println(a+"*"+b+" resolution is a "+j+"K resolution.");
}
else{
System.out.println("Cannot be categorized at any K_notation.");
}
}
else if(a>b){
double ja=K_notation(a);
double jb=K_notation(b);
if(ja>=1){
System.out.println(a+"*"+b+" resolution is a "+ja+"K resolution.");
}
else
{
System.out.println("Cannot be categorized at any K_notation.");
}
if(ja>=1 && jb>=1){
System.out.println(a+"*"+b+" resolution is a "+ja+"K"+jb+"K
resolution.");
}
else
{
System.out.println("Cannot be categorized at any 2 dimensional
K_notation.");
}
}
else{
double ja=K_notation(b);
double jb=K_notation(a);
if(ja>=1){
System.out.println(a+"*"+b+" resolution is a "+ja+"K resolution.");
}
else
{
System.out.println("Cannot be categorized at any K_notation.");
}
if(ja>=1 && jb>=1){
System.out.println(a+"*"+b+" resolution is a "+ja+"K"+jb+"K
resolution.");
}
else
{
System.out.println("Cannot be categorized at any 2 dimensional
K_notation.");
}
}
}
}

import java.util.Scanner;
public class Graphic_Demo {
public static void main(String[] args) {
Scanner injector = new Scanner(System.in);
int w, h;
System.out.print("Enter horizontal pixel count:");
w=injector.nextInt();
System.out.print("Enter vertical pixel count:");
h=injector.nextInt();
Graphic.Aspect_ratio(w,h);

Graphic.K_notation_resolution(w,h);
}
}

You might also like