Skhendle / Java_Projects

This repository is for projects I do for refining and enhancing my Java Skills.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java_Projects Build Status

This repository is for projects I do for refining and enhancing my Java Skills. With some question from the Udemy course: Become A Professional Java Developer From Scratch.

TaskOne

Topic: I/O, conditionals statements and loops.

Question:

Count positive and negative numbers and compute the average of numbers. Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values. Your program ends with the input 0. Display the average as a floating-point number.

TaskTwo

Topic: I/O, conditionals statements and loops.

Question:

Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the name of the student with the highest score

TaskThree

Topic: Basics of classes and their functionality

Question:

Design an “Account” class. The class will have fields id(int), balance(double), annualInterestRate(double), and a “ Date “ field named dateCreated(just use Date date = new Date() ). It will have two constructors, a no argument constructor that will create a default account and a constructor with arguments id, balance, annualInterestRate, and Date, that will create an account with the specified parameters. All fields are private and will have getters and setters, except the date field which will not have a setter only a getter. You will also create a withdraw method to withdraw money from the account, a deposit method to add money to the account.

TaskFour

Topic: Inheritance and Polymorphism

Question:

Design a “ Person “ class. The class will have fields name, last name, age, and address. Those fields are going to be private and you will also create getters and setters in order to modify those fields. Create two constructors, one with no arguments which will set those fields to any value that you wish and other constructor with arguments name, last name, age and address to set up all those fields.

TaskFive

Topic: Abstract classes

Questions:

  1. Design a class named “ Student “ that will inherit from the “ Person “ class that you created in exercises in chapter 3. The new class will also have fields studentID, semester(which will tell at which semester is that student (max 8)), major(which will tell what the student is studying), and department(which will tell at which department of the college is the student studying). The class will have a no argument constructor, and also a constructor that will initialize all those variables and it will also class the super() to initialize the variables of the super class. It will also have getters and setters for all of those fields.

  2. Design a class named “ Instructor “ that will inherit from the “ Person “ class that you created in exercises in chapter 3. The new class will have instructorID, degree(which will tell if the instructor has a bachelor, master or PHD), classesTeaching(which will tell how many classes is the instructor teaching), major(which will tell what is the instructor teaching), department(which will tell at which department of the university is the instructor teaching), yearsWokring(which will tell how many years is the instructor working at the university), salary(which will tell the salary of the instructor). The class will have a no argument constructor, and also a constructor that will initialize all those variables and it will also class the super() to initialize the variables of the super class. It will also have getters and setters for all of those fields.

TaskSix

Topic: Exception Handling in Java

Questions:

  1. NumberFormatException - Write a program that will calculate two numbers, it can be division, multiplication etc, and displays the result to the user. The program terminates when you type a non numeric character. NOTE: Write this program using exception handling, and then write this program without using exception handling to achieve the same objective.

  2. ArrayIndexOutOfBoundsException - Write a program that meets the following requirements:

■ Creates an array with 100 randomly chosen integers.

■ Prompts the user to enter the index of the array, then displays the corresponding element value. If the specified index is out of bounds, display the message Out of Bounds .

#Note: Could not manage to contine executing the program after throwing the exception for the first question

TaskSeven

Topic: Reading and writing to files

Task:

The code creates a text.txt file in the directoey it is being runned in, and writes content worth three lines. It then opens the file and reads the lines in the file and numbers them.

TaskEight

Topic: Binary Input/Output.

Task:

(Sum all the integers in a binary data file ) Suppose a binary data file has been created and its data are created using writeInt(int) in DataOutputStream. The file contains an unspecified number of integers. Write a program to find the sum of the integers.

TaskNine

Topic: Reading websites.

Task:

This program gets the html content of the specified website and writes the content in a text file called text.txt

About

This repository is for projects I do for refining and enhancing my Java Skills.


Languages

Language:Java 100.0%