Question

In: Computer Science

Create your own Java program that has all three of these components in its design: Includes...

Create your own Java program that has all three of these components in its design:

  • Includes file input OR file output (one of the two)
  • Uses token-based processing of String, int, double, or boolean (your choice)
  • Incorporates two additional methods in addition to the main() method: one that's a value-returning method, the other a void.

Solutions

Expert Solution

The code for the above program is given below and comments are added in code for your understanding:

import java.io.FileInputStream;

public class MemberTest {
     

   public static void main(String[] args) {
      
       ///example of fileinput
       try{
   FileInputStream input=new FileInputStream("filehello.txt");
   int i=input.read();
   System.out.print((char)i);
  
   input.close();
   }catch(Exception e)
               {
       System.out.println(e);
       }
       //example of file input ends
  
      
   }
  
   //this is the method which return some value
   public int valueReturning()
   {
       return 8;
      
   }
   //this is the method for void
   public void hello()
   {
       System.out.println("Hello from void");
   }
      
  
}

Please refer to the screenshot of the code for identation of the code:

Thank You!


Related Solutions

Create a program in java with the following information: Design a program that uses an array...
Create a program in java with the following information: Design a program that uses an array with specified values to display the following: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Initialize an array with these specific 20 numbers: 26 45 56 12 78 74 39 22 5 90 87 32 28 11 93 62 79 53 22 51 example...
Design a Java program named LambdaTester2 which includes a main method that declares a lambda expression...
Design a Java program named LambdaTester2 which includes a main method that declares a lambda expression reference which implements the following interface: interface Multiplier {     int multiply(int num1, int num2); } The program must declare an array of Pair objects (see class specification below), followed by the declaration of an ArrayList which is instantiated using the declared array (the ArrayList stores Pair objects). Then write a loop which iterates through each element of the ArrayList, calls the lambda expression reference...
in Java, Create a class called EMPLOYEE that includes three instance variables – a first name...
in Java, Create a class called EMPLOYEE that includes three instance variables – a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test app names EmployeeTest that demonstrates class EMLOYEE’s capabilities. Create two EMPLOYEE objects and display each object’s yearly...
WRITE CODE IN JAVA it is now your turn to create a program of your choosing....
WRITE CODE IN JAVA it is now your turn to create a program of your choosing. If you are not sure where to begin, think of a task that you repeat often in your major that would benefit from a program. For example, chemistry unit conversions, finding the area for geometric shapes, etc. You can also create an interactive story that changes based on the user input/decisions. The possibilities are endless. The program must include instructions for the user. Be...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a package named threeDimensional and put all 3 of the classes discussed below in this package Include a header comment to EACH OF your files, as indicated in your instructions. Here's a link describing the header. Note that headers are not meant to be in Javadoc format. Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class,...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a package named threeDimensional and put all 3 of the classes discussed below in this package Include a header comment to EACH OF your files, as indicated in your instructions. Here's a link describing the header. Note that headers are not meant to be in Javadoc format. Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class,...
Java Create a class named Billing that includes three overloaded computeBill() methods for a photo book...
Java Create a class named Billing that includes three overloaded computeBill() methods for a photo book store. main() main() will ask the user for input and then call functions to do calculations. The calculations will be returned to main() where they will be printed out. First function Create a function named computeBill that receives on parameter. It receives the price of an item. It will then add 8.25% sales tax to this and return the total due back to main()....
Design your own "Stout" beer. Include the malt and grain components and their percentages of each.
Design your own "Stout" beer. Include the malt and grain components and their percentages of each.
Create a java program that: - Has a class that defines an exception -Have that exception...
Create a java program that: - Has a class that defines an exception -Have that exception throw(n) in one method, and be caught and handled in another one. -Has a program that always continues even if incorrect data is entered by the user -has a minimum of 2 classes in it
Write a java program that can create, read, and append a file. Assume that all data...
Write a java program that can create, read, and append a file. Assume that all data written to the file are string type. One driver class and a class that contains the methods. The program should have three methods as follows: CreateFile - only creating a file. Once it create a file successfully, it notifies to the user that it creates a file successfully. ReadingFile - It reads a contents of the file. This method only allow to read a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT