the java homework assignments
Exploring Java Programming: A Comprehensive Guide to Homework Assignments
Java is a powerful and versatile language. Since it first appeared in 1995, it has become one of the most widely used programming languages. It is taught at every level of computer science and is also used for a wide variety of industrial tasks. In this respect, Java is similar to C, C++, and Perl. These languages offer a technological dividend: learning them requires significant upfront time investment, but once learned, they can be used to solve a wide range of problems. But while industry is willing to pay this dividend for C, C++, and Perl, can we really afford to ask the same of our students? The short answer is yes. The slightly longer answer involves discussing a few real problems that are currently being solved using Java. It turns out that practical programming tasks are not only engaging but can also be used to teach the core concepts of the computer science curriculum; in that connection, Java offers a synergy that is not possible with other languages.
We use Java in subject I2194, Programming 2, a sophomore-level course that is a continuation of I2104, Programming 1. I2104 is the first course in computer science and is taught using the Scheme programming language. Java and Scheme offer the technological divorce (at least, they do so in early-to-mid 2000). Unlike the more industrial languages, these languages help us focus upon the core themes in computing: procedural and declarative problem solving, recursion, abstraction, and polymorphism. In I2104, our main focus is on these basic themes. Basic Java (and conventional computer science) topics are covered as well, and they are the major topics that students explore in six programming assignments. This chapter introduces Java programming by exploring, in detail, the first of these six programming assignments. Before reading this chapter, be sure that you can read and write Java code and that you are familiar with the Java development environment. At the time of this writing, we use Java on the Solaris server.
Java is an object-oriented high-level programming language developed by Sun Microsystems. It originated as a platform-independent language, or program that can be written on any operating system and then run anywhere. The motive behind the Java programming language’s development was to create an object-oriented language that could be applied to any software application type, including applets (programs embedded in the Web), servlets (programs that run on servers), standalone applications, and other enterprise solutions (like Ecommerce and EJB). The abilities to create network-aware, web-enabled applications or platform-independent, object-oriented applications make Java a preferred programming language.
2.1 Basic Java Concepts Java is a clustering of programs known specifically as the Java Development Kit (JDK). Both the Java runtime system and the Java compiler are included in this kit, permitting development and application of Java applets or Java applications. Java virtual machine (JVM) and Java API The role of the Java Virtual Machine (JVM) is to provide an abstracted set of instructions for any platform. A Java program is compiled through the Java Virtual Machine and then executed on the host or client operating system. No native library code has to be written for the client machine because the Java API manages all such calls for the individual platform. Since the Java API can handle all the calls, it provides the ability to operate on any machine and within any environment unlike C++ or Visual Basic. Subvariants of the Micro JVM are available for devices with high limitations and devices requiring truly tiny environments, such as pagers, PDAs, cellular phones, and wristwatches.
In this chapter, we introduce the basic data types of the Java programming language. We will use these data types extensively throughout the rest of the book. We also introduce the concept of variables and assignment statements.
3.1 Variables and Assignment Statements Java programs store data in memory while executing. We use variables to refer to this data so that we can keep track of it. We first specify the identity of a variable by using a variable declaration statement. Then we assign a value to this variable by using an assignment statement.
Variable and Assignment Statement Example This program sets up a variable of type int named aSampleVariable and assigns it the value of 7. It then prints the value of this variable to the console window.
class aProgram { public static void main(String[] args) { int aSampleVariable = 7; System.out.println(aSampleVariable); } }
Data Type Java programs are strongly typed. The type of a variable refers to the type of data that the variable can store or represent. When we declare a variable, we must tell Java which type the variable is and what type of value the variable can hold.
Variable Declaration A variable declaration statement allows us to specify some characteristics of a variable. The declaration statement tells the program the name of the variable and of what type of values the variable will refer to. Only values of this variable’s specified type can be stored in this variable.
Variable Initialization We initialize a declared variable by creating an assignment statement for the variable. We use the equal sign with the variable’s name on the left and the value that this variable will refer to on the right. The value that this variable will now point to is known as the initializer.
Control Structures
Java provides a variety of control structures to define loops and conditional branches. These control structures can be nested to create composite actions. Most of the time, a simple sequence of statements is not enough to achieve your programming task. The execution of a program can be interrupted by specific events. In addition, you need the ability to react differently to the event based on different situations.
Just to give you an example, the execution of a program usually starts at the beginning of the main routine and continues until it reaches the end. However, sometimes you want to execute only specific statements depending on certain conditions.
In the Java programming language, you have different ways to realize the flow of control in a program, which means that Java programs can execute statements in a sequence, jumping from one statement to another depending on the result of a specific condition. This is known as the flow of control in a program. The basic control flow for an executable block of Java code is simple and linear, that is, it always executes one statement after another. Often, it may be necessary to alter the flow of control in a program. This is called a branching mechanism. The most common branching mechanisms in a program are the “if”, “if-else”, “switch”, and the conditional expressions in Java. This item will discuss these control structures.
Sometimes, programmers need to execute a block of code repeatedly for different values or until a condition is met. The iterative mechanism is used to repeatedly execute a part of the code in Java. This mechanism will be discussed later in this chapter; you will learn about the “while”, “do-while”, and “for” loop structures. The use of loop control statements will also be touched upon.
Methods
Complete (or revise) the Java methods described below. Also, complete (or revise) the comments appropriately. Adams will provide you with a complete description only after three to seven groups have submitted their solutions. Java provides substring methods for Strings. To concatenate the end of a String, you can leave off the second argument (or use the length method to find position of the end of the String). Alice has found some eating methods useful for fast-food. Extend the program and provide input data to verify that the Eating methods implement the requirements.
A meeting room scheduler consists of classes and methods. For example, add two parameters to the scheduleMeeting method. Can you improve the meeting room scheduler by locating time slots for all meetings that are appended to the existing schedule from a list of proposed meeting times using additional methods for a duration test, a test for calculating the next time slot, and a method for making a new meeting request?
Classes
Follow the instructions, sample event occurrences, and previously described classes and methods to add outputs for the Date class. Provide and verify the code that implements the month incrementation, the next day of the year, and the day of the calendar week calculations and the month method. Also, add another getters/setters to your portfolio class.
We offer essay help by crafting highly customized papers for our customers. Our expert essay writers do not take content from their previous work and always strive to guarantee 100% original texts. Furthermore, they carry out extensive investigations and research on the topic. We never craft two identical papers as all our work is unique.
Our capable essay writers can help you rewrite, update, proofread, and write any academic paper. Whether you need help writing a speech, research paper, thesis paper, personal statement, case study, or term paper, Homework-aider.com essay writing service is ready to help you.
You can order custom essay writing with the confidence that we will work round the clock to deliver your paper as soon as possible. If you have an urgent order, our custom essay writing company finishes them within a few hours (1 page) to ease your anxiety. Do not be anxious about short deadlines; remember to indicate your deadline when placing your order for a custom essay.
To establish that your online custom essay writer possesses the skill and style you require, ask them to give you a short preview of their work. When the writing expert begins writing your essay, you can use our chat feature to ask for an update or give an opinion on specific text sections.
Our essay writing service is designed for students at all academic levels. Whether high school, undergraduate or graduate, or studying for your doctoral qualification or master’s degree, we make it a reality.