Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you make two classes from these program like asked in this question and can plz changd the program to for while mport javax.swing.; class

image text in transcribed
image text in transcribed
image text in transcribed
can you make two classes from these program like asked in this question
image text in transcribed
image text in transcribed
and can plz changd the program to for while
mport javax.swing."; class lab_two // main class public static void main(String[] args) { String m - JOptionPane.showinput Dialog("Enter street number,street,city, province, postal code with space"); //asking user to enter details if(null) { //checks it input is null if it is null progran exit System.exit(1) // else continues String[] al-m.split(" ")//calling address class address ad new address(al); //declaring the object ad.print(); //printing the output 1 lass address private int a; //declaring the private int a to store street number private String s1, 52, 53, 54; // and string for storing other details address(String m) // creating the constructor if( [0]--pull){ // checks li street number it existe street Number_verify); // if no it ask to enter ) else{ 4 - Integer.parseInt(0); //else continue 3 01. m11 //assigning the value street 82 - m2); // assigning the value city 53 - 311 // assigning the value province if(m 41 wpull){ //checks it postal code is null postal_coder); // if calls the function to enter > else { 84 m 11 else assigning the value 64-4.replace(",).trim(); // adding the spaces to postal code ) public void setAlint a) (1/set functions for street number this.a - 1 > public boolean sets String sl) ( //set method for street thin. (1. isimpty)) //cheeks if it exista return false; // if no returns talle public boolean Bets1(String sl) (l/set method for street this.al - 1(sl.isEmpty()) { //check it it exists return false; // if no returns false > return true; // else returns true > public boolean sets2(String 82) { //set nethod for city this.s2 - 52: if (2.isEmpty(){ //checke if it exists return false;// if no return false > return true; // else returns true > public boolean set3(String 3) this.3-83: 13.isEmpty()[//checks if it exists return false;//it no return false Return true; // else returns true ) public boolean Nets4String 84) this.14 - 341 if (3.isEmpty() //checke if it exists return false;//if no returns Ealse return true; // else returns true > publie boolean street Number_verify // verify function for street number String al Integer.tostring(a): 77 converts int to string because i am unable to check int is null if(al. isimpty()) { // cheeks if it is null -Integer.parseInt(JoptionPane.showinputDialog("Enter street nunber"); // ask to enter sota):// calls the set method else { return true; // else return true 1 return false; // else false return false;//1f no returns false > return true; // else returns true ) public boolean street.Number_verifyx // verify function for street number String al Integer.toString(): 77 converts int to string because i am unable to check int is null if(a.isEmpty() // checks if it is null a-Integer.parseInt(JOptionPane.showInput Dialog("Enter street number")); // ask to enter setAfa); // calls the set method ) else return true; // else return true > return false; // else false public boolean postal code(){ // verity method for postal code if(d.isempty(){ // checks af it is null 54-JoptionPane.showInput Dialog("Enter postal code number); // If ask to enter set54(4): // calls the setsd method ) else return true; //return true > return false; // else false void print // prints the output it the values are true if (postal code Systen.out.println("Street number:"+a); Itset81(1) System.out.println("street"+81) if(sets202)) Syaten.out.println("City:***2); Itsets () Syaten.out.println("Province: +33) ) Itsets(14 System.out.println("Postal code:+4) oratory assignment, create a Java program that prompts the user for an address in pieces, and then presents their 1 of 1 address. For example, prompt for their street number, street, city, province, and postal code. Use a JOptionPane input dialog to get the Strings, and a JOption message dialog to present the completed address Your program should consist of two classes a lab two class (give this class an appropriate name), and an Address class. The first class contains the main method and prompts the user for Strings, while the second class contains the data and methods for storing and synthesizing the address. Your Address class should contain private data members. Use accessor methods to set and retrieve the five data members (one int and four Strings). Each access method to set a value should have a String parameter, and return true if the value was set and false otherwise. The accessor methods to retrieve a value should take no parameters, and return an intor String as appropriate. Your setStreetNumber and setPostalCode accessor methods should verify a correct format before returning true to indicate the value has been set. For example, the number should be a valid number, and the postal code should be a valid postal code (letter, number, letter, number, better number and only six or seven (with a space) digits long.). A valid postal code may or may not contain a space, but should be stored with a space. Your Address class must override the toString method and return a String, which is the address to display to the user Your main method should keep prompting for a street number or postal code until a valid entry is given. If the user should select the cancel button for any input, your program should exit Example Code for JOptionPane string sjoptionPane, showinputDialog("Message Goes Here"); 11(s = null) { CM string s = JoptionPane.showInput Dialog("Message Goes Here"); 1 of 1 if(s == null) System.exit(1); 3 joptionPane showMessageDialog(null, s, "MyMessage", JoptionPane . INFORMATION MESSAGE ); This code snippet is here for you to use if you want. You do not necessarily need to do it this way Submission Use JavaDoc to comment your program, remembering to comment each class and method. Include your name, student ID. class, and assignment type and number in a regular comment, at the top of each source file. Remember to run the command Javadoc filename for both classes (if you have them in separate files). When your program is completed, demonstrate it to the instructor, and upload your java source files to Moodle with a screen shot, all in a jar file. Use the jar .cf LastName_Lab2.jar Lab2 command to put it in a jar file. Assignments that do not compile or run may be awarded a mark of zero... Enjoy :) Hints: You may want private isNumber() and isLetter() functions. mport javax.swing."; class lab_two // main class public static void main(String[] args) { String m - JOptionPane.showinput Dialog("Enter street number,street,city, province, postal code with space"); //asking user to enter details if(null) { //checks it input is null if it is null progran exit System.exit(1) // else continues String[] al-m.split(" ")//calling address class address ad new address(al); //declaring the object ad.print(); //printing the output 1 lass address private int a; //declaring the private int a to store street number private String s1, 52, 53, 54; // and string for storing other details address(String m) // creating the constructor if( [0]--pull){ // checks li street number it existe street Number_verify); // if no it ask to enter ) else{ 4 - Integer.parseInt(0); //else continue 3 01. m11 //assigning the value street 82 - m2); // assigning the value city 53 - 311 // assigning the value province if(m 41 wpull){ //checks it postal code is null postal_coder); // if calls the function to enter > else { 84 m 11 else assigning the value 64-4.replace(",).trim(); // adding the spaces to postal code ) public void setAlint a) (1/set functions for street number this.a - 1 > public boolean sets String sl) ( //set method for street thin. (1. isimpty)) //cheeks if it exista return false; // if no returns talle public boolean Bets1(String sl) (l/set method for street this.al - 1(sl.isEmpty()) { //check it it exists return false; // if no returns false > return true; // else returns true > public boolean sets2(String 82) { //set nethod for city this.s2 - 52: if (2.isEmpty(){ //checke if it exists return false;// if no return false > return true; // else returns true > public boolean set3(String 3) this.3-83: 13.isEmpty()[//checks if it exists return false;//it no return false Return true; // else returns true ) public boolean Nets4String 84) this.14 - 341 if (3.isEmpty() //checke if it exists return false;//if no returns Ealse return true; // else returns true > publie boolean street Number_verify // verify function for street number String al Integer.tostring(a): 77 converts int to string because i am unable to check int is null if(al. isimpty()) { // cheeks if it is null -Integer.parseInt(JoptionPane.showinputDialog("Enter street nunber"); // ask to enter sota):// calls the set method else { return true; // else return true 1 return false; // else false return false;//1f no returns false > return true; // else returns true ) public boolean street.Number_verifyx // verify function for street number String al Integer.toString(): 77 converts int to string because i am unable to check int is null if(a.isEmpty() // checks if it is null a-Integer.parseInt(JOptionPane.showInput Dialog("Enter street number")); // ask to enter setAfa); // calls the set method ) else return true; // else return true > return false; // else false public boolean postal code(){ // verity method for postal code if(d.isempty(){ // checks af it is null 54-JoptionPane.showInput Dialog("Enter postal code number); // If ask to enter set54(4): // calls the setsd method ) else return true; //return true > return false; // else false void print // prints the output it the values are true if (postal code Systen.out.println("Street number:"+a); Itset81(1) System.out.println("street"+81) if(sets202)) Syaten.out.println("City:***2); Itsets () Syaten.out.println("Province: +33) ) Itsets(14 System.out.println("Postal code:+4) oratory assignment, create a Java program that prompts the user for an address in pieces, and then presents their 1 of 1 address. For example, prompt for their street number, street, city, province, and postal code. Use a JOptionPane input dialog to get the Strings, and a JOption message dialog to present the completed address Your program should consist of two classes a lab two class (give this class an appropriate name), and an Address class. The first class contains the main method and prompts the user for Strings, while the second class contains the data and methods for storing and synthesizing the address. Your Address class should contain private data members. Use accessor methods to set and retrieve the five data members (one int and four Strings). Each access method to set a value should have a String parameter, and return true if the value was set and false otherwise. The accessor methods to retrieve a value should take no parameters, and return an intor String as appropriate. Your setStreetNumber and setPostalCode accessor methods should verify a correct format before returning true to indicate the value has been set. For example, the number should be a valid number, and the postal code should be a valid postal code (letter, number, letter, number, better number and only six or seven (with a space) digits long.). A valid postal code may or may not contain a space, but should be stored with a space. Your Address class must override the toString method and return a String, which is the address to display to the user Your main method should keep prompting for a street number or postal code until a valid entry is given. If the user should select the cancel button for any input, your program should exit Example Code for JOptionPane string sjoptionPane, showinputDialog("Message Goes Here"); 11(s = null) { CM string s = JoptionPane.showInput Dialog("Message Goes Here"); 1 of 1 if(s == null) System.exit(1); 3 joptionPane showMessageDialog(null, s, "MyMessage", JoptionPane . INFORMATION MESSAGE ); This code snippet is here for you to use if you want. You do not necessarily need to do it this way Submission Use JavaDoc to comment your program, remembering to comment each class and method. Include your name, student ID. class, and assignment type and number in a regular comment, at the top of each source file. Remember to run the command Javadoc filename for both classes (if you have them in separate files). When your program is completed, demonstrate it to the instructor, and upload your java source files to Moodle with a screen shot, all in a jar file. Use the jar .cf LastName_Lab2.jar Lab2 command to put it in a jar file. Assignments that do not compile or run may be awarded a mark of zero... Enjoy :) Hints: You may want private isNumber() and isLetter() functions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago