This repository was archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJournal.java
More file actions
64 lines (49 loc) · 2.37 KB
/
Copy pathJournal.java
File metadata and controls
64 lines (49 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Aim: b) Define a class called Journal that could be used to store an entry for a research paper that
// will be published. The class should have instance variables to store the author’s name, title of
// the paper, and the date of submission using the Date class from this chapter. Add a constructor
// to the class that allows the user of the class to set all instance variables. Also add a method,
// displayDetails , that outputs all the instance variables, and another method called
// getSubmissionDetails that returns the title of the paper, with the first letter of each word
// capitalized. Test your class from the main method.
package com.College_Java_Lab.Exp_3_Classes_and_Objects;
import java.util.Scanner;
public class Journal {
String author_name, title, date_of_submission;
Journal( String name, String title, String date){
this.author_name = name;
this.title = title;
this.date_of_submission = date;
}
public void displayDetails (){
String [] date = this.date_of_submission.split("/",3);
System.out.println( "Author is " + this.author_name );
System.out.println( "Title is " + this.title );
System.out.println( "Submitted on " + date[2] + "/" + date[1] + "/" + date[0] );
}
public void getSubmissionDetails(){
for ( int i = 0; i < this.title.length(); ++i ){
if( i != 0 && this.title.charAt(i-1) == ' ' )
System.out.print(Character.toUpperCase(this.title.charAt(i)));
else
System.out.print(this.title.charAt(i));
}
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String author_name = input.nextLine();
String title = input.nextLine();
String date_of_submission = input.nextLine();
Journal book = new Journal( author_name, title, date_of_submission );
book.displayDetails();
book.getSubmissionDetails();
}
}
// Input:
// Hichem Zorgati
// Program instrumentation and run-Time analysis of Scoped Memory in Java
// 2005/12/01
// Output:
// Author is Hichem Zorgati
// Title is Program instrumentation and run-Time analysis of Scoped Memory in Java
// Submitted on 01/12/2005
// Program Instrumentation And Run-Time Analysis Of Scoped Memory In Java