SlideShare a Scribd company logo
Create the Version class
- data members (integers)
- major
- minor
- service pack
- setter for each data member
- allow for cascading calls
- getter for each data member
- use PLP and handle constant objects
- use the class in main()
- prompt the user to enter major, minor, and service pack release
numbers
- use cascading member function calls
- assign all data members in one statement using setters
- display the version by calling getter for each data member, have the
getter just return the value of the data member
Example:
Major: 10
Minor: 1
Service Pack: 1
Solution
package automativ;
import java.util.*;
public class version {
int major;
int minor;
int serviepack;
version(int major,int minor,int serviepack){
setmajor(major);
setminor(minor);
setserviepack(serviepack);
}
private void setserviepack(int serviepack) {
this.serviepack=serviepack;
}
private void setminor(int minor) {
this.minor=minor;
}
private void setmajor(int major) {
this.major=major;
}
public int getmajor(){
return major;
}
public int getminor(){
return minor;
}
public int getserviepack(){
return serviepack;
}
}
main class:
package automativ;
import java.util.*;
public class mymainever {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("enter major:");
int major=sc.nextInt();
System.out.println("enter minor:");
int minor=sc.nextInt();
System.out.println("enter servicepack:");
int servicepack=sc.nextInt();
version v=new version(major,minor,servicepack);
int majorf=v.getmajor();
int minorf=v.getminor();
int servicepackf=v.getserviepack();
System.out.println("major is:"+majorf);
System.out.println("minor is:"+minorf);
System.out.println("servicepack is"+servicepack);
}
}
output:
enter major:
10
enter minor:
1
enter servicepack:
1
major is:10
minor is:1
servicepack is1

More Related Content

PDF
Explain what factors underlying the signaling specificity and the sp.pdf
PDF
Can anyone help me with this oneWhich falls outside the study of .pdf
PDF
As the sender of important or critical information, what actions sh.pdf
PDF
1. Montessori schools emphasizeA. group activities and projects.pdf
PDF
Compare and contrast woven and secondary cortical bone. Mention 4 si.pdf
PDF
The hardness of bone is primarily due to a combination of collagen an.pdf
PDF
The following statements are on general IO operations and Interrupts.pdf
PDF
Sympatric speciation is _____.initiated by the appearance of a geogr.pdf
Explain what factors underlying the signaling specificity and the sp.pdf
Can anyone help me with this oneWhich falls outside the study of .pdf
As the sender of important or critical information, what actions sh.pdf
1. Montessori schools emphasizeA. group activities and projects.pdf
Compare and contrast woven and secondary cortical bone. Mention 4 si.pdf
The hardness of bone is primarily due to a combination of collagen an.pdf
The following statements are on general IO operations and Interrupts.pdf
Sympatric speciation is _____.initiated by the appearance of a geogr.pdf

More from donohovalentinj6 (20)

PDF
What is the evolutionary advantage of an exoskeleton A. it waterpro.pdf
PDF
What is the probability that 5 out of 7 offspring in a monohybrid F2.pdf
PDF
What are the characteristics of lifeSolutionAnswerChatac.pdf
PDF
What all does the SHOW statement do in MySQLSolutionAs the co.pdf
PDF
Using MATLAB (code must be written for MATLAB) and the concept of Ho.pdf
PDF
three fossils are found in undisturbed layers of rock, or strata. Fo.pdf
PDF
Use the rank correlation coefficient to test for a correlation betwe.pdf
PDF
Think about what you now know about project delivery systems. Are th.pdf
PDF
The brain stem is the link between what two parts What two structur.pdf
PDF
SQL(workbench) Write a script that contains the CREATE TABLE statem.pdf
PDF
Since 1942, Ernst Mayr defined species as populations that can re.pdf
PDF
Question Help More Info The beginning inventory numbers are as follow.pdf
PDF
please answer to all of the questions and write neatly. Other exer.pdf
PDF
On anatomy atlases org or in your text study the process of spermatog.pdf
PDF
Multiple choice questions please help.Janzen restored the pasturela.pdf
PDF
Nitrogen is key to cellular growth. It is usually acquired from the a.pdf
PDF
Let S1 and S2 be the matrices of the symmetry with respect to the ve.pdf
PDF
is a set of logically related ideas and symbols that represent what w.pdf
PDF
2) A group of scientists is studying two populations of elephant.pdf
PDF
I have a CSI case to prosecute for Biology and I need to find the co.pdf
What is the evolutionary advantage of an exoskeleton A. it waterpro.pdf
What is the probability that 5 out of 7 offspring in a monohybrid F2.pdf
What are the characteristics of lifeSolutionAnswerChatac.pdf
What all does the SHOW statement do in MySQLSolutionAs the co.pdf
Using MATLAB (code must be written for MATLAB) and the concept of Ho.pdf
three fossils are found in undisturbed layers of rock, or strata. Fo.pdf
Use the rank correlation coefficient to test for a correlation betwe.pdf
Think about what you now know about project delivery systems. Are th.pdf
The brain stem is the link between what two parts What two structur.pdf
SQL(workbench) Write a script that contains the CREATE TABLE statem.pdf
Since 1942, Ernst Mayr defined species as populations that can re.pdf
Question Help More Info The beginning inventory numbers are as follow.pdf
please answer to all of the questions and write neatly. Other exer.pdf
On anatomy atlases org or in your text study the process of spermatog.pdf
Multiple choice questions please help.Janzen restored the pasturela.pdf
Nitrogen is key to cellular growth. It is usually acquired from the a.pdf
Let S1 and S2 be the matrices of the symmetry with respect to the ve.pdf
is a set of logically related ideas and symbols that represent what w.pdf
2) A group of scientists is studying two populations of elephant.pdf
I have a CSI case to prosecute for Biology and I need to find the co.pdf

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Lesson notes of climatology university.
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
master seminar digital applications in india
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Final Presentation General Medicine 03-08-2024.pptx
Complications of Minimal Access Surgery at WLH
2.FourierTransform-ShortQuestionswithAnswers.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Lesson notes of climatology university.
STATICS OF THE RIGID BODIES Hibbelers.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
master seminar digital applications in india
Final Presentation General Medicine 03-08-2024.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
A systematic review of self-coping strategies used by university students to ...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
202450812 BayCHI UCSC-SV 20250812 v17.pptx

Create the Version class          - data members (integers)     .pdf

  • 1. Create the Version class - data members (integers) - major - minor - service pack - setter for each data member - allow for cascading calls - getter for each data member - use PLP and handle constant objects - use the class in main() - prompt the user to enter major, minor, and service pack release numbers - use cascading member function calls - assign all data members in one statement using setters - display the version by calling getter for each data member, have the getter just return the value of the data member Example: Major: 10 Minor: 1 Service Pack: 1 Solution package automativ; import java.util.*; public class version { int major; int minor; int serviepack; version(int major,int minor,int serviepack){ setmajor(major); setminor(minor); setserviepack(serviepack); }
  • 2. private void setserviepack(int serviepack) { this.serviepack=serviepack; } private void setminor(int minor) { this.minor=minor; } private void setmajor(int major) { this.major=major; } public int getmajor(){ return major; } public int getminor(){ return minor; } public int getserviepack(){ return serviepack; } } main class: package automativ; import java.util.*; public class mymainever { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("enter major:"); int major=sc.nextInt(); System.out.println("enter minor:"); int minor=sc.nextInt(); System.out.println("enter servicepack:"); int servicepack=sc.nextInt(); version v=new version(major,minor,servicepack); int majorf=v.getmajor();
  • 3. int minorf=v.getminor(); int servicepackf=v.getserviepack(); System.out.println("major is:"+majorf); System.out.println("minor is:"+minorf); System.out.println("servicepack is"+servicepack); } } output: enter major: 10 enter minor: 1 enter servicepack: 1 major is:10 minor is:1 servicepack is1