Java Programming Language And Development Computer Science

Essay add: 21-10-2016, 18:22   /   Views: 4

Java is a most popular language in the world and than it used to develop everything from web application to cell-phone tools to space vehicles. So, Java is a high-level and third generation programming language. Java is use to write computer applications such as moment of truth numbers, method words, play games, store data or do any of the thousands of other things computer software. If knowing how to program in C++, than will certainly to learn Java more quickly. The special of Java in relation to other programming languages is that it to write individual programs called applets that can download from Internet. In traditional computer programs have distant too much access to the system to be a downloaded. Although it usually trust the maintainers of various ftp archives and statement boards to do basic virus checking and not to post negative software, a lot still slips during the cracks. Even more dangerous software would be promulgating if any web page be visit can run programs on the system. Therefore, it is no way of checking these programs for bugs or for out-and-out malicious behavior before downloading and running them. Java be solves the problem by severely restrict what an applet can do. A Java applet cannot write to the hard disk without user agreement. It cannot write to random address in the memory and thereby to introduce a virus into user computer. It should not crash the system.

Java does not have a lot of clutter to get in the way, and because it was built from the ground up with modern programming concepts. One of the primary goals of the Java language developers is on the way to remove any aspects of languages such as C and C++ that were determined to be overly complicated and irrelevant. Java does not have a large number of constructs, and thus it is small and simple to understand. However, do not equate simplicity with inferiority; Java is a powerful language indeedâ€" much like English. After all, even though the English alphabet has only 26 letters, those letters can be combined in virtually limitless ways! Part of ensuring Java’s simplicity involved creating the syntax of the language itself. Java looks a lot like C++, a language with which many developers are familiar. If, become a javascript programmer, it must comfortable writing Java code because the syntax is similar. Don’t think for a minute that this simplicity somehow results in a trivial language, though. Java is powerful, but its simplicity makes for straightforward access. After all, programmers want to produce solid code without having to twist their mind into knots trying to understand what they are doing. Java programs are easier to create than programs in a comparable language such as C++, but the results can be equally forceful.

Question 1

Write a program using looping to get the following output.

1)while loop

2)for loop

Enter your choice:1

Using while loop

***************

Do you wish to continue? (Y/N): Y

1)while loop

2)for loop

Using for loop

***************

Do you wish to continue? (Y/N): N

Answer of Question 1

import java.util.Scanner;

public class Assignment_1 {

public static void main(String[]args) {

{

System.out.println("(1)For Loopn");

System.out.println("(2)While Loopn");

System.out.println("***********************************");

System.out.println("--Enter your choice--:");

System.out.println("***********************************");

Scanner input = new Scanner(System.in);

char x = input.next().charAt(0);

if(x=='1')

{

System.out.println("***********************************");

System.out.println("ttUsing For Looptt");

System.out.println("***********************************");

int d;

for(d=1;d<=5;d++)

{

System.out.print(" ");

int e;

for(e=1;e<=d;e++)

{

System.out.print("* ");

}

System.out.println("");

}}

else if(x=='2')

{

System.out.println("***********************************");

System.out.println("ttUsing While Looptt");

System.out.println("***********************************");

int a=1;

while(a<=5)

{

int b=1;

while (b<=a)

{

System.out.print("* ");

b++;

}

System.out.println("");

a++;

}}

else

{

System.out.println("***********************************");

System.out.println("tt[ "+x+" ] #Invalid INPUT!#t");

}

int loop;

for(loop=1;loop>0;loop++)

{

System.out.println("***********************************");

System.out.print(" Do you wish to continue?(Y/N) : ");

char yn1 = input.next().charAt(0);

if(yn1=='Y' || yn1=='y')

{

System.out.println("***********************************");

main(args);

}

else if(yn1=='N' || yn1=='n')

{

System.out.println("***********************************");

System.exit(0);

}

else

{

System.out.println("***********************************");

System.out.println("tt[ "+yn1+" ] #Invalid INPUT!#tt");

}}}}}Output

Figure 1

First step is entering the choice then the output will show out the output at figure 2.

Figure 2

After, choice than the output will show out the output using for loop. If want continue then tab y means yes.

Figure 3

Just now at figure 2 have mention if want to continue the output loop then choice yes to continue.

Figure 4

After choice then the output will show out using while loop.

Figure 5

After, finish choice then the output will ask again want to continue the output. Do want continue then tab n mean no. The system will be process completed.

Figure 6

If tab wrong number then the output will show out this is invalid input.

Question 2

Write a program using switch statement for the following output.

month

statement

1

January

2

February

3

March

4

April

5

May

6

Jun

7

July

8

August

9

September

10

October

11

November

12

December

Answer of Question 2

import java.util.Scanner;

public class Assignment_2

{

public static void main(String[]args)

{

Scanner scanner = new Scanner(System.in);

System.out.print("*****************************n");

System.out.print("tPlease enter a monthn");

System.out.print("*****************************n");

int month = scanner.nextInt();

System.out.print("*****************************n");

switch (month)

{

case 1:System.out.println("tt*January*");

break;

case 2:System.out.println("tt**February**");

break;

case 3:System.out.println("tt***March***");

break;

case 4:System.out.println("tt****April****");

break;

case 5:System.out.println("tt*****May*****");

break;

case 6:System.out.println("t******June******");

break;

case 7:System.out.println("t*******July*******");

break;

case 8:System.out.println("t********August********");

break;

case 9:System.out.println("t*********September*********");

break;

case 10:System.out.println("t**********October**********");

break;

case 11:System.out.println("t***********November***********");

break;

case 12:System.out.println("t************December************");

break;

default:System.out.println("t*****Invalid month*****");

}}}Output

Figure 7

Figure 8

Figure 9

Conclusion

In the conclusion, Java Programming is not only as a profitable language but also as an education language. I know that Java is a language for writing web pages such as HTML. Hence, Java is easy to learn if know how to using programming C and C++. Java code is portable. Each implementation decides the storage requirements for basic data types such as short, int, float, double, and etc. Java also can be extended to do anything the machine can do. Such as play movie, make sounds or other. As a language, Java is suitable for building large applications. Java Programming is most computer science departments can agree to use as an early language. In the addition, this assignment is using control structure to write the program. There are including for loops, while loop and switch statement. Therefore, for loop is specifies the number controlled repetition details in a single line codes. Than the while loop is a repetition statement which allows specifying that program should repeat an action. By the switch statement checks all cases and executes the statement in the matched case.

Finally, in this assignment I have learned how to design a program and write a program. When, we started to run the program and end the program.

Article name: Java Programming Language And Development Computer Science essay, research paper, dissertation