Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this assignment, you will write a Java program to print the first 15 Fibonacc

ID: 3850843 • Letter: I

Question

In this assignment, you will write a Java program to print the first 15 Fibonacci numbers. Each number must occupy one line, with even numbers having a * appending to it. You must include your name, class number, instructor name, a pledge in your comment. Indention must be used for any sub-blocks: any sub-block must use 2 space characters more than its parent block.

Here is a sample:

//Name: John Kat

//Time: Sept. 21, 2016

//Class: Programming with UNIX, section 8

//Instructor: John kat /*Pledge: I, john kat, did not receive any help for this programming assignment.*/

//a sample program class …

Submit a copy of your program, the result from running your program before class

Explanation / Answer

Hi, I am attaching a java code here.

Please use comments and package name as per your guidelines

Code:

//Name: John Kat
//Time: Sept. 21, 2016
//Class: Programming with UNIX, section 8
//Instructor: John kat /*Pledge: I, john kat, did not receive any help for this programming assignment.*/

package javaapplication2;

public class JavaApplication2
{
public static void main(String[] args)
{
int n1=0,n2=1,n3;
//we already know first and second number
//lets print them
System.out.println(n1);
System.out.println(n2);
  
//lets print remaining 13 numbers
for(int i=2;i<15;i++)
{
n3=n1+n2;
if(n3%2==0)
{
System.out.println(n3+"*");
//as you can see, we are appending * in front of even numbers
}
else
{
System.out.println(n3);
}
n1=n2;
n2=n3;
}
}   
}

Output:

0
1
1
2*
3
5
8*
13
21
34*
55
89
144*
233
377