## Java Netbeans Assignment Solution

• 14th Sep, 2021
• 23:49 PM
```Write a program using for-loop to display the following table from 1 to 10 miles.

/*
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package program1;

import java.util.Scanner;

public class prog1 {

public static void main (String [] args)
{
int Miles;
int i;

System.out.println("Miles\tKilometers");
double kilometer = 0;

for (i=1;i<=10;i++)
{ kilometer=kilometer + 1.609;

System.out.println(i+"\t"+kilometer+"\t");

}
}
}

/*
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package program1;

import java.io.IOException;
import java.util.Scanner;

public class prog2

{
public static void main(String args[]) throws IOException

{
int choice = 0;
do
{
int n;

Scanner in = new Scanner(System.in);
System.out.println("Enter an integer(0 is to end the game) ");
n = in.nextInt();

if (n==0)
{
System.out.println("End of the game");
System.exit(0);
}
else if(n%5!=0&&n%6!=0)
System.out.println(n+" is not divisible by 5 or 6");
else if(n%5==0 && n%6==0)
System.out.println(n+" is divisible by 5 and 6 ");
else if (n%5==0|| n%6==0)

System.out.println(n+" is divisible by 5 and 6 but not both ");

}

while(choice==0);
//System.out.println("End of the game");
}
}

```