Home Answers Viewqa Java-Beginners classes and data abstraction

 
 


sassy
classes and data abstraction
2 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners

View Answers

January 8, 2009 at 3:32 AM


Hi friend,


I am sending java code according to your requirement. Please implement following code.


public class Exchange {

private String type;
private double amount;
private int convert;

public Exchange() {

}

public void setType(String type){
this.type = type;
}

public String getType(){
return type;
}

public void setAmount(double amount){
this.amount = amount;
}

public double getAmount(){
return amount;

}

public void setConvert(int convert){
this.convert = convert;
}

public int getConvert(){
return convert;
}
}
-------------------------

January 8, 2009 at 3:33 AM


import java.io.*;

public class ExchangeDemo {

public static void main(String args[]) throws IOException{

Exchange ex = new Exchange();
System.out.println("U S doller currency Amount Example!");
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
String str="y";
while(str.equals("Y")||str.equals("y")){

System.out.println("Please enter currency type!");
String a = buff.readLine();
ex.setType(a);

System.out.println("Please enter u s amount!");
double b = Double.parseDouble(buff.readLine());
ex.setAmount(b);
System.out.println("U S doller currency " + b);

System.out.println("Please enter convert amount!");
int c = Integer.parseInt(buff.readLine());
ex.setConvert(c);

System.out.println("doller type currency :" +ex.getType());
System.out.println("U S doller currency :" + ex.getAmount());
System.out.println("Exchange currency :" + ex.getConvert());

System.out.print("would you like to Continue y or n:");
str=buff.readLine();
}
}
}

-------------------------------------------------------

Visit for more information:

http://www.roseindia.net/java/language/inheritance.shtml

Thanks.









Related Pages:
classes and data abstraction - Java Beginners
classes and data abstraction  Create a java program for a class named Exchange that contains data member methods that meet the criteria... in Lab 8.1. These data members are private members so that they cannot
Abstraction in Java
Abstraction in Java Abstraction is one of the four pillar of OOPS Concept. Abstraction in java is a process by which hiding the irrelevant data  and exposing only the essential feature of object. In java Abstraction
What is Abstraction - Java Beginners
What is Abstraction  What is abstraction in java? How is it used in java..please give an example also  Hi Friend, Abstraction is nothing but data hiding.It involves with the dealing of essential information
Java abstraction - Java Beginners
Java abstraction  what is abstraction in java please explain with example  Hi, Abstract Class Abstract classes are those that works... the methods inherited from the abstract class (base class). Abstract classes
abstraction
abstraction  give a simple example program for abstraction   public class Animal { double energyReserves; boolean isHungry() { return... is an abstraction used in place of an actual animal
abstraction
abstraction  give a simple example program for abstraction  ... is an abstraction used in place of an actual animal.*/   public class Animal...); } } } /*In the above example, the class Animal is an abstraction used in place
how to do abstraction for insurance policy being issued...
how to do abstraction for insurance policy being issued...  an insurance policy is being insured.... now what will be the classes for policy and how to do abstraction of the same
Encapsulation VS Abstraction - Java Beginners
and Abstraction. where to use abstract and where to use specifies like public... of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way
Java Data Objects
Java Data Objects       The Java Data Objects (JDO) API is a specification of Java model abstraction... to the domain model. JDO persistent objects are simple java classes therefore
wrapper classes
wrapper classes  Explain wrapper classes and their use?   Java Wrapper Class Wrapper class is a wrapper around a primitive data type. It represents primitive data types in their corresponding class instances e.g.
Difference between Encapsulation and Abstraction in Java
and Abstraction in Java. Encapsulation is a process of hiding all the data and methods within a class from outside world. Abstraction on the other hand... and protected access modifier. It wraps the variables, method data and codes within
Classes and Objects
Classes and Objects       Objects and classes are the fundamental parts of object-orientated programming technique. A class can contains both data as well as methods. A simple class having no method must
Classes in Java
Classes in Java      ...; A Stream is a sequence of data. An Input Stream is used by the program to read data from the source. Similarly, a program uses an Output stream to write data
Abstraction in flex
Abstraction in flex  Hi... What keyword allows you to implement abstraction better? please tell me about it.... Thanks   Ans: Flex does not support abstart class directly. Thanks
Collection classes in java
is the reason using java collection classes saved/stored the data/content.I don't.... Or the data is stored in both database and java collection classes...Collection classes in java   Normally a database is used
Collection classes in java
is the reason using java collection classes saved/stored the data/content.I don't.... Or the data is stored in both database and java collection classes...Collection classes in java   Normally a database is used
Wrapper Classes
Wrapper Classes        In this section you will learn about Wrapper classes and all the methods that manipulate data and allows to operate a certain work. Wrapper class
Advanced Concepts with Classes - JDBC
Advanced Concepts with Classes  Advanced Concepts with Classes... you Employees in a company are divided into the classes Employee, HourlyPaid... wages or monthly salaries. The data to be maintained for each class may
Summary: Classes, Interfaces
Java: Summary: Classes, Interfaces Packages package package-name; Class Definition A class definition prototype: visibility class class-name... to be a node: class Node { int data; Node next; // methods
Java FontMetrics classes
and FontMetrics classes?  The Font class provides mappings to fonts that are used to render text data onto the screen. The Font class maps... mappings to fonts that are used to render text data onto the screen. The Font
Inheritance, abstract classes
a little lost with child classes, but here goes and don't know what to call... field. I created two child classes of Account: Checking and Savings. Within... to write an application named AccountArray in which you enter data for a mix of 10
Classes and Objects
Classes and Objects       Objects and classes are the fundamental parts of object-orientated programming technique. A class can contains both data as well as methods. A simple class
Java abstraction - Java Beginners
Java abstraction  Is abstraction and abstract class are related ar same
encapsulation vs abstraction
encapsulation vs abstraction  what is the difference between encapsulation and abstraction
Classes-Objects in JavaScript
Classes-Objects in JavaScript   ... Classes and Objects of JavaScript and create the examples of Classes and Objects... is a special kinds of data and it contains the properties and methods. JavaScript
Spring Web Annotation Classes
of instruction, syntax or meta data that provides data about the program... be used with the classes or methods or both. It is used to specify the handler classes or methods that handles the particular request. /* Used with Class
Abstraction : Java Glossary
Abstraction : Java Glossary   .... Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts... creation process, programmatically. Here we will discuss Abstraction briefly
Abstraction in java - Java Interview Questions
Abstraction in java  Abstraction in java - I know its a very basic question that i can find anywhere else as well... but i am looking for a description as well as an example on Abstraction in java. can anyone
Encapsulation & Abstraction - Java Interview Questions
Encapsulation & Abstraction  What is the difference between Encapsulation and Abstraction
Encapsulation & Abstraction - Java Interview Questions
Encapsulation & Abstraction  What is the difference between Encapsulation and Abstraction
Java Get classes In Package
Java Get classes In Package   ... the classes from the package by providing the path of the jar file and the package... and the positions of   the stream at the beginning of the entry data. The class
Classes and Interfaces of the I/O Streams
Classes and Interfaces of the I/O Streams       Classes: The following listing of classes...;ByteArrayInputStream It contains the internal buffer and read data from
How to make query and abstraction in Java
How to make query and abstraction in Java  Hi, I read the lessons you have in the sites. They are really useful. However, I could not write codes... PostgreSQL database, and I want to make a query and abstraction for a table. Could
Abstraction in Java 7
Abstraction in Java 7 This section elaborate about abstraction. It is one of OOPs concept. Abstraction :  Abstraction means hiding the unnecessary... or object.  In java, you can see concept of abstraction whenever you use
Wrapper Classes
Primitive Wrapper Class In this section you will learn about Wrapper classes and all the methods that manipulate data and allows to operate a certain work. Wrapper class is a wrapper around a primitive data type. It represents
Pattern,Matcher,Formatter and Scanner classes
Pattern,Matcher,Formatter and Scanner classes This section Describes : 1... to format or parse strings or streams. 2. Uses of the Pattern and Matcher classes... using the Formatter and Scanner classes and the PrintWriter.format/printf
URGENT: User Defined Classes - Java Beginners
://www.roseindia.net/java/java-get-example/index.shtml Here, you will get different data
ABSTRACTION AND INTERFACE - Java Interview Questions
ABSTRACTION AND INTERFACE  When Use Abstract?When Use Interface ?I Want Explanations?plz help me  Hi Friend, When we do not want to allow any one to create object of our class, we define the class as abstract. When
Classes in Java
Classes in Java      ...; A Stream is a sequence of data. An Input Stream is used by the program to read data from the source. Similarly, a program uses an Output stream to write data
OOPS Concept Abstraction with example - Java Beginners
OOPS Concept Abstraction with example  I am new to java. In java OOPS concept Abstraction means abstract or something. Please explain it with one example  Hi Friend, The process of abstraction in Java is used
Abstract Factory Pattern
of abstraction higher than factory pattern. This means that the abstract factory returns the factory of classes. Like Factory pattern returned one of the several sub-classes, this returns such factory which later will return one of the sub-classes
Java classes
Java classes  Which class is extended by all other classes
DAO Classes
DAO Classes  login page code for Dao classes
Java Data Objects
JDO - Java Data Objects   ... and benefits of JDO specification. The Java Data Objects or JDO for short is Java's... Java model abstraction of persistence, developed as Java Specification Request
java classes
java classes  Which class is the super class for all classes in java.lang package
Inner classes
Inner classes   Hi I am bharat . I am student learning java course . I have one question about inner classes . question is how to access the instance method of Non-static classes which is defined in the outer

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.