Premium Essay

Java Codes

In:

Submitted By iandelacruz23
Words 3114
Pages 13
Ian Carlos C. Dela Cruz Comp 102 IT-1A

Exercise No.1 import java.io.*; public class JavaApplication3 {

/** * @param args the command line arguments */ public static void main(String[] args) throws IOException{ // TODO code application logic here InputStreamReader ian = new InputStreamReader(System.in); BufferedReader reading = new BufferedReader(ian); double a,b,c,ave; System.out.print("\tRainfall for April: "); a= Double.parseDouble(reading.readLine()); System.out.print("\tRainfall for May: "); b= Double.parseDouble(reading.readLine()); System.out.print("\tRainfall for June: "); c= Double.parseDouble(reading.readLine()); ave = (a+b+c)/3; System.out.print("\tAverage Rainfall: " + ave );

}
}
Exercise No. 2 import java.io.*; public class Trigonometry { public static void main(String args[])throws IOException{ InputStreamReader ian = new InputStreamReader(System.in); BufferedReader reading = new BufferedReader(ian); System.out.println("Input value:"); Double number = Double.parseDouble(reading.readLine()); Double sine = Math.sin(number); Double cose = Math.cos(number); Double sum = sine + cose; System.out.println("sine: " + sine + " \tcosine: " + cose + " \tsum: " + sum );

Exercise No. 3

import java.io.*; public class DegreestoRadians { public static void main(String args[])throws IOException{ InputStreamReader x = new InputStreamReader(System.in); BufferedReader reading = new BufferedReader(x ); System.out.print("Input degrees: ");

Similar Documents

Free Essay

Java - Download and Study the Code Provided

...com/download-and-study-the-code-provided-in-the-bluej-project/ Follow this link to get the tutorial http://helpido.com/download-and-study-the-code-provided-in-the-bluej-project/ Download and study the code provided in the BlueJ project roman_numerals_buggy.zip. Rename this BlueJ project to roman_numeral_soln (this is the BlueJ project you will be submitting). You can rename the project by renaming the folder from roman_numerals_buggy to roman_numeral_soln after extracting the zip file. The purpose of this code is to convert Arabic numerals into Roman numerals. Make an instance of RomanNumerals and invoke the method toRoman(int n). Enter a number in the Arabic notation and it will convert it to a Roman numeral. For example “17” will be converted to “XVII”.You will notice a test suite that we provide with the code. Run the test suite by right-clicking on RomanNumeralsTest and choosing Test All as shown in Figure 6.3 of the book. Alternatively, you can click on the Run Tests button as shown in Figure 6.2 of the book, if you have enabled the ‘Show unit testing tools’ preference. To enable it, go to Tools > Preferences > Miscellaneous, and select ‘Show unit testing tools’. You will notice a total of eight tests of which two fail. Your first task in this assignment is to study the given code, identify why the two tests fail, and correct the code. On studying the code further, you will notice a few more bugs/limitations in the provided code (i.e. the provided code will not...

Words: 568 - Pages: 3

Premium Essay

Codes in Java Netbeans

...Database connection /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package scholapaymentsystem; import com.mysql.jdbc.Connection; import java.sql.DriverManager; import java.sql.SQLException; /** * * @author ferdie_amy */ public class DBConnection { private Connection DBConnection; public Connection connect(){ try{ Class.forName("com.mysql.jdbc.Driver"); System.out.println("connection succed"); } catch(ClassNotFoundException cnfe){ System.out.println("connection failed" + cnfe); } String url = "jdbc:mysql://localhost:3306/db_login"; try{ DBConnection = (Connection) DriverManager.getConnection(url,"root", ""); System.out.println("database connected"); } catch (SQLException se){ System.out.println("connection failed" + se); } return DBConnection; } } LOGIN FORM /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package scholapaymentsystem; import java.awt.event.KeyEvent; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql...

Words: 36130 - Pages: 145

Free Essay

.Net and Java Technology Comparison

....NET & Java Comparsion Activity Zeferino Reyes CSS - 422 December 12, 2011 Nasser Alaeddine .NET & Java Comparison Activity In this written document will focus on the advantages and disadvantages or the use of .NET technology in use compared to the use of JAVA Technology as Software Architecture, (University of Phoenix, 2010, 2009, 2008, 2007, 2006, 2005). .NET technology is the means to “connect” meaning connecting software, people, structures, things like printers, networks, computers, anything one can think of, (Getdotnnu.com, 2004-06). JAVA Technology is known to be adaptable where it can connect computers to networks, mobile phones to the internet, and game consoles such as the new Playstation 3, Xbox 360, and Nintendo Wii to the internet to access web browsing, built in plug in like Netflix to watch movies, and to other consoles for online gaming like the popular shooter Call of Duty. Advantages of .NET technologies are that it has the ability to grab internet servers that web services and tools such as internet apps or anything that can produce these services. One profitable feature of .NET is its ASP.net technologies that allows for the making of additional websites and net services that exist on the .NET infrastructure, (Getdotnu.com, 2004-06). Another powerful advantage of .NET technology is the ASP feature is that it creates construction sites, services and applications and does not require as much coding as the older coding in the beginning...

Words: 705 - Pages: 3

Free Essay

Sd2720 Module 1 Java Basics Refresher

...SD2720 Module 1 Java Basics Refresher Click Link Below To Buy: http://hwcampus.com/shop/sd2720-module-1-java-basics-refresher/ Lab 1.1 Creating Java Application In this lab, you will complete three tasks related to Java classes, their attributes, and error handling in a Java program. The task performed in this lab will help you understand how to break a complex software program into various classes by using object-orientated programming. Task 1 Scenario: Universal Bank offers various services to its customers. The bank has various branches all over the country and therefore, each branch has a unique code. The bank stores the details of its customers such as customer ID, customer name, account number, address, phone number, and email address. In addition, the bank offers its customers a choice of accounts, such as savings account, current account, and loan account. In addition, the bank stores its employee details, such as employee code, employee name, employee address, phone number, and email address. For the given scenario, complete the following: • Identify the various classes and their attributes used in this scenario. • Create a UML class diagram depicting the relationship among classes for the customer and employee information system of Universal Bank. • Create the Java code to implement the identified classes. • Assign values to the identified attributes. • Display the attribute values. Task 2 Scenario: Royal College offers different...

Words: 528 - Pages: 3

Free Essay

Web 238 Team Assignment

... and then creatively enhanced with CSS. To create a visually expressive Web site that can attract thousands of visitors each day you need to use more than HTML and decide what the site contains. There are different languages that can be used to add a sense of style to your site, some of the possible devices are JavaScript, Java, DOM, and AJAX. In the following paper our team will discuss a few examples of how each can be used in Web development. Comparison of Java and JavaScript Java and JavaScript are both object-oriented languages (Burns, 2012). Knowing how to use one language often becomes confusing when attempting to learn the other. Some of the differences between the two are that Java applets can create stand-alone applications that work across platforms running as standalone programs. However, JavaScript cannot create these stand-alone applications and reside on an Internet browser. A programmer must compile Java code before the program can run. This requires an outside program just to compile the code. A compiler turns Java code into machine language code before a browser can interpret it. Any changes the programmer makes to the code will require him to recompile the program and this can be a real tedious act to commit over and over. A web designer can write JavaScript functions directly in a text editor, saving the file and upload it to the server for immediate execution or using an editor like Adobe Dreamweaver that allows for...

Words: 2442 - Pages: 10

Premium Essay

My It Report

...MICHAEL OKPARA UNIVERSITY OF AGRICULTURE, UMUDIKE P.M.B 7267, UMUAHIA, ABIA STATE. A TECHNICAL REPORT ON A SIX MONTHS STUDENT INDUSTRIAL WORK EXPERIENCE CARRIED OUT AT ASHPOT MICROSYSTEMS LIMITED, 142 MARKET ROAD ABA. BY ELEANYA IFEANYICHI FAVOUR MOUAU/BSC/10/11/2222 SUBMITTED TO THE DEPARTMENT OF COMPUTER SCIENCE IN PARTIAL FULFILMENT FOR THE AWARD OF BACHELOR OF SCIENCE (BSc) DEGREE IN COMPUTER SCIENCE. DECEMBER 2013 DECLARATION I ELEANYA IFEANYICHI FAVOUR with the matriculation number MOUAU/BSc/10/11/2222, hereby declare that I underwent six months of industrial training at ASHPOT MICROSYSTEMS LIMITED, 142 market road Aba and that this report is written by me to the best of practical knowledge acquired during the course of the training program. DEDICATION This report is dedicated to God almighty for his grace upon my life and for seeing me through in the course of my industrial training, and to my wonderful family for their tireless support, love, and advice up to this point of academic pursuit. CERTIFICATION We the undersigned hereby certified that ELEANYA IFEANYICHI FAVOUR with the registration number MOUAU/BSC/10/2222, has duly completed her six months Industrial Training at Ashpot Microsystem Limited Aba, in partial fulfillment of the requirements for the award of Bachelor of Science (B.Sc...

Words: 1843 - Pages: 8

Free Essay

Important Things in File

...class file in Java 1. class file in java is generated when you compile .java file using any Java compiler like Sun's javac which comes along JDK installation and can be found in JAVA_HOME/bin directory. 2. class file contains byte codes. byte codes are special platform independent instruction for Java virtual machine. bytecode is not a machine language and mere instruction to JVM. since every machine or processor e.g. INTEL or AMD processor may have different instruction for doing same thing, its left on JVM to translate bytecode into machine instruction and by this way java achieves platform independence. 3. class file of inner class contains $ in there name. So if a Java source file contains two classes, one of them is inner class than java compiler will generate two class file. separate class file for top level and inner class. you can distinguish them by looking at there name. Suppose you have top level class as "Hello" and inner class as "GoodBye" then java compiler will generate two class file: Hello.class Hello$GoodBye.class Hello$GoodBye.class is a class file for inner class. whose name is in format of top-class$inner-class. 4. You can look bytecode of class file using javap command. javap command can also display method and field information from .class file. see my post how to decompile .class file in Java for more details. 5. class file format is subject to change and its changed to support new feature introduced in Java 1.5. In general every java compiler and...

Words: 573 - Pages: 3

Premium Essay

Asdsada

...UNIVERSITY College of Computer Studies Introduction to Programming Activity Book Compiled by: Mark Godfrey D. Torres 2012 Introduction to Programming ii Table of Contents Weeks 1 to 3 – Creating Your First Java Classes ....................................................................................... 1 Objectives ........................................................................................................................................... 1 Summary ............................................................................................................................................ 1 The Don’ts........................................................................................................................................... 2 Key Terms ........................................................................................................................................... 3 Seatwork............................................................................................................................................. 6 Where to Save Your Files ................................................................................................................. 6 Configuring Windows to Work with the Java SE Development Kit................................................... 6 Your First Application ...................................................................................................................... 8 Adding...

Words: 4647 - Pages: 19

Premium Essay

Harshit

...commercially-friendly open source software. Its projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. The Eclipse Project was originally created by IBM in November 2001. The vast majority of Android apps owe their existence to Eclipse. It is an open source IDE (integrated development environment) for Java projects (and more). Basically, the place where the application software is crafted is supported through various stages of its lifecycle. Google officially supports it, and has created the Android Development Tools plug-in for Eclipse and integrated its AVD Manager virtual device management into the tool as well. SDK The Android SDK (software development kit) is a set of development tools used to develop applications for Android platform. The Android SDK includes the following: * Required libraries * Debugger * An emulator * Relevant documentation for the Android application program interfaces (APIs) * Sample source code * Tutorials for the Android OS Every time Google releases a new version of Android, a corresponding SDK is also released. To be able to write programs with the latest features, developers must download and install each version’s SDK for the particular phone.  Emulator The emulator lets you prototype, develop and test Android applications without using a physical device. The Android emulator mimics all of the hardware...

Words: 1324 - Pages: 6

Premium Essay

Is Technology Moving Faster Than Ethics ??

...All of the above 5. Circle all that apply. Which of the following lines is not a Java comment? a) b) c) d) e) /** comments */ // comments -- comments /* Comments */ ** comments ** 1 6. For each software development concept below indicate whether it applies at design time, runtime, or both. You should circle one letter on each line. The first line is an example. Compiling source files Logic errors Syntax errors a) Design time a) Design time a) Design time b) Runtime b) Runtime b) Runtime c) Both c) Both c) Both 7. Which Java operator is used to access variables and methods belonging to an object? a) b) c) d) e) The [] operator The -> (arrow) operator The _ (underscore) operator The . (dot) operator None of the above 8. Suppose you’ve written a Java class called Quadratic. To create an object variable using that class you should write the following: a) b) c) d) Quadratic equation = Quadratic(); Quadratic() = new Quadratic; Quadratic equation = new Quadratic(); Quadratic equation = new Equation(); 2 B) Fill in the Blanks 9. The Java primitive type ____________ uses 16 bits to store positive and negative whole number values. 10. Examine the following code fragment: 1. int value = 12; 2. value = value * (3/2); 3. value = value % 2; 4. value = value - 11; 5. value = value / 3; 6. System.out.println("value"); Fill in the value of the variable ‘value’ after each line of code runs. 1....

Words: 604 - Pages: 3

Premium Essay

Prg 420

...Read Me First Introduction JAVA™ IS A FULL-FEATURED, GENERAL-PURPOSE PROGRAMMING LANGUAGE WITH MANY CAPABILITIES. IT CAN SERVE AS A STANDALONE LANGUAGE FOR A VARIETY OF APPLICATIONS, INCLUDING DESKTOP AND SOME MOBILE PROGRAMS. THIS COURSE CLOSELY ALIGNS WITH THE ORACLE CERTIFIED ASSOCIATE JAVA™ SE EXAMINATION. Course Overview Week One includes an overview of how programming languages work and an introduction to Java™ and the Java™ Virtual Machine (JVM). The JVM is what enables the same Java™ program to run unchanged on multiple platforms. You learn Java™ syntax by writing a program that compiles and executes. You begin with the simplest programs that display a message to the user; however, the structure that you use carries forward into more complex programs later on. Week Two focuses on two of the most important concepts in programming: selection and repetition. Selection allows you to make a choice between alternatives and determine which block of statements will be executed as a result. Repetition allows the program to repeat a block of code multiple times. This enables you to write programs that can do a lot of processing with very few lines of code. For example, you may want to read all of the records in a data file. With a repetition structure, you can write this in just a few lines. If repetition structures were not available, you would have to write a line of code for every record in the file. In Week Three, you will look at methods and constructors in...

Words: 553 - Pages: 3

Free Essay

Unit 5 Reseach Assignment

...object-oriented structure also allows code to be reused a lot, which can cut down development time. C++ is also a fairly efficient language - although many C programmers will disagree. 2. C is a popular language, especially in game programming, because it doesn't have the extra packaging of the object-oriented C++. Programmers use C because it makes programs slightly faster and smaller than programs written in C++. You might wonder, however, whether it's worth giving up the reusability of C++ to get the small increase in performance with C, especially when C++ can, where necessary, be written in a C programming style. 3. Pascal is primarily a teaching language. Few industrial programs are written in Pascal. Pascal tends to use keywords instead of C-style braces and symbols, so it is a bit easier for beginners to understand than languages like C++. Still, not everyone thinks Pascal is just for the schools. Borland, the huge compiler software company, has been pushing Delphi as an industrial strength programming language. Delphi is an object-oriented version of Pascal, and currently, only Borland compilers use it. 4. Java is a multi-platform language that is especially useful in networking. Of course, the most famous usage of Java is on the web, with Java applets, but Java is also used to build cross-platform programs that stand alone. Since it resembles C++ in syntax and structure, learning Java is usually quite easy for most C++ programmers. Java offers the advantages provided by...

Words: 1233 - Pages: 5

Premium Essay

Tic Tac Toe Java Code

...OBJECT ORIENTED PROGRAMMING TIC TAC TOE Contents: Page 1. Specifications 3 2. Background 4 3. UML Design i. Use Case Diagram 5 ii. Class Diagram 6 4. Implementation i. How code is working? 7 ii. Conclusion 9 iii. Future Work 10 5. Appendix 10 6. References 15 7. Bibliography 15 1. Specifications: A requirements specification for a software system - is a complete description of the behavior of a system to be developed. It includes a set of use cases that describe all the interactions the users will have with the software. Use cases are also known as functional...

Words: 1071 - Pages: 5

Premium Essay

Java

...Mohammad Doush Mr. Matthew Robert English 103 13 April 2013 Java the Programming Language Computer is very important in our live, we use computer in everywhere on our live. The doctor uses the computer to see file or pictures of his patients. Also, each engineer uses it in many ways of his work. The teacher in the classroom, employees in the offices and student in their study all of them use computer in them daily live. They are not using the mouse, the keyboard or the scream. They are using the applications by them these applications in the computer are like the soul in the body. The only way to build these applications is programming. To program we need to know one of the programming languages which are very similar each other. If you are professional in one of these languages you can be professional in the other language in a short period of time. It is acceptable if you have the same application written with Java once and with C++ or C sharp at the same time. So for this reason you cannot say that a programming language is better than others. There are three types of programming languages procedural, functional and object-oriented languages. The most uses of these languages are object-oriented and one of these languages is Java you can write any application you need using it. Also you can translate any application to its word. The message of the High-Level programming languages such as Algol and Pascal in first programming revolution was...

Words: 2352 - Pages: 10

Premium Essay

Sport

...Computer Science What is java? Java is an object-oriented language, which is a type of programming in which programmers define both the data type of a data structure and the type of operations that can be applied to the data structure. There are more languages that are object-oriented for example C++ and Pascal. Java is very similar to C++ but has been simplified to eliminate language features that cause common errors in the program. Java was designed to be like C++ but easier to use so it had the ‘look and feel’ but simpler to use Java is commonly used foundations for developing and delivering content on the web. There are more than 9 million Java developers world-wide and more than 3 billion phones run on java. Java can be used to create complete applications that may run on a single computer or be distributed among servers and the clients in a network. Another use of java is it can be used to build a small application module or more commonly known as an applet for use as part of a web page. This allows interaction with the page. What is IDE? Integrated development environment (IDE) is a programming environment integrated into a software application that provides a GUI (Graphical User Interface) builder, text or code editor, a complier (this analyses and executes each line of source code (look below for a diagram)) and/or interpreter (This executes instructions written in a high level language (Java, C++, etc.) and a debugger (This is a program that finds errors...

Words: 365 - Pages: 2