Posts

Showing posts from January, 2018

OOP lab 11

Image
SOURCE CODE: import java.util.Scanner; public class ExceptionDemo   {     public static void main(String[] args)     {         Scanner input = new Scanner(System.in);                             int donutCount, teaCount;         double donutsPerGlass = 0;          try          {             System.out.println("Enter number of donuts:");                  donutCount = input.nextInt( );             System.out.println("Enter number of cup of tea:");     ...

OOP lab 10

1.   Reading Input From Text Files Designing and implementing Java programs that deal with: 1.       Reading Input From Text Files a.        Create a File object and give it the name of the file. \\ the file in the current folder File myFile01 = new File(“Message.txt”); \\ full path using the back slash File myFile02 = new File(“D:\\CSC210\\Lab10\\READ.TXT”); \\ full path using the forward slash File myFile03 = new File(“D:/CSC210/Lab10/READ.TXT”); \\ the current directory File myFile04 = new File(“.”); b.        Pass the File object to a Scanner object to read from it. Scanner reader01 = new Scanner(myFile01); ยบ Steps a and b can be combined as: Scanner reader01 = new Scanner(new File(“Message.txt”); c.         Use the methods of the Scanner class normally, i.e., hasNextInt , nextInt , next , nextDouble , etc. reader01.h...

OOP lab 8

Image
Exercise 1                                                                                                                                              Design and implement a subclass “ EquilateralTriangle ” having a double variable side denoting the three sides of the equilateral triangle [No...