csci04
DESCRIPTION
”The two authors further analyses their study that “the majority of FB users reported that it did not impact their academic performance to not using FB frequently enough for such an effect to occur. They also emphasized that academics were a priority for them. Second, of the FB users reporting an impact, the majority indicated a negative impact citing procrastination behaviour on their part. These students reported having poor time management skills and that FB use allows them to put off studying while not giving them the feeling that they are “not working”; evidenced by their statements that FB was beneficial to their learning (i.e., of the FB users reporting an impact, respondents claimed to use it as a networking tool for academic purposes). Clearly, they place the locus of control of their FB use and its effects outside of FB and in their own personalities.”TRANSCRIPT
![Page 1: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/1.jpg)
CSCI04: Java Programming Case Studies
Submitted by:
Tacata, Jerome E. 10500038
Aton, Ronnel 10500231
Conde, Henry 10500049
Raposon, Lilmar John 10500166
Chan, Manuel O. 10500095
Moreno, Von 10500040
Course:
Bachelor of Science in Information Technology
Sumbitted to: Engr. Darius A. Añonuevo
MSIT and BSCOE
Professor, AMA Las Piñas
Date Submitted: December 12, 2012
1
![Page 2: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/2.jpg)
II. TABLE OF CONTENTS
I. Front Page ……………………………………………………………. p. 1
II. Table of Contents ……………………………………………………. p. 2
III. Program Questionnaire ……………………………………………… p. 3
IV. Program Source Code ………………………………………………. pp. 4-7
V. Program Output ………………………………………………………. p. 8
VI. Reference ……………………………………………………………… p. 9
2
![Page 3: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/3.jpg)
III. PROGRAM QUESTIONNAIRE
Create an abstract class named book. Include a string field for the book's title
and a double field for the book's price within the class, include a constructor that
requires the book title and add two get methods, one that returns the title and one
that returns the price. Include an abstract method named setPrice() Create two child
classes of book Fiction and non-Fiction each must include a setprice() methods that
sets the price for all fiction books to $24.99 and for all non-fiction books to $37.99
Write a constructor for each subclass, and include a call to set price within each.
Write an application demonstrating that you can create both a fiction and a non-
fiction book, and display their fields. Save the file as book.java, fiction.java,
nonfiction.java and usebook.java.
Additionally, write an application named book array in which you create an array
that holds 10 books, some fiction and some nonfiction. Using a for loop, display
details about all 10 books. Save the file as bookArray,java.
3
![Page 4: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/4.jpg)
IV. PROGRAM SOURCE CODE EXPLANATION
Book.java
public abstract class Book
{
String title = new String();
double price;
public Book(String t)
{
title = t;
}
public String getTitle()
{
return title;
}
public double getPrice()
{
return price;
}
public abstract void setPrice();
}
4
![Page 5: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/5.jpg)
UseBook.java
public class UseBook {
public static void main(String[] args) {
Fiction aFinn = new Fiction("Huckelberry Finn");
NonFiction aStyle = new NonFiction("Elements of Style");
System.out.println("Fiction " + aFinn.getTitle() + " costs $"
+ aFinn.getPrice());
System.out.println("Non-Fiction " + aStyle.getTitle() + " costs $"
+ aStyle.getPrice());
}
}
Fiction.java
public class Fiction extends Book
{
public Fiction(String title)
{
super(title);
setPrice();
}
public void setPrice()
{
super.price = 24.99;
}
}
5
![Page 6: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/6.jpg)
NonFiction.java
public class NonFiction extends Book
{
public NonFiction(String title)
{
super(title);
setPrice();
}
public void setPrice()
{
super.price = 37.99;
}
}
6
![Page 7: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/7.jpg)
BookArray.java
public class BookArray
{
public static void main(String[] args)
{
Book Book[] = new Book[10];
int s;
Book[0] = new Fiction("Scarlet Letter");
Book[1] = new NonFiction("Introduction to Java");
Book[2] = new Fiction("Mill on the Floss");
Book[3] = new NonFiction("The Road Not Taken");
Book[4] = new Fiction("A Tale of Two Cities");
Book[5] = new NonFiction("Europe on $5 a Day");
Book[6] = new Fiction("War and Peace");
Book[7] = new Fiction("A Simple Plan");
Book[8] = new Fiction("Disclosure");
Book[9] = new Fiction("Nancy Drew");
for(s = 0; s < Book.length; ++s) {
System.out.println("Book: " + Book[s].getTitle() + " costs $"
+ Book[s].getPrice());
}
}
}
7
![Page 8: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/8.jpg)
V. PROGRAM OUTPUT
Output # 1
Output # 2
8
![Page 9: CSCI04](https://reader035.vdocuments.site/reader035/viewer/2022071807/55cf9c05550346d033a8451b/html5/thumbnails/9.jpg)
VI. REFERENCES
- www.google.com
- www.youtube.com
- http://www.roseindia.net/java/java-get-example/
- http://www.codemiles.com/java/what-is-an-abstract-class-t578.html
- http://www.dreamincode.net/forums/topic/217047-using-abstract-class/
- http://www.youtube.com/watch?v=TyPNvt6Zg8c
9