Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using the work on the previous assignment, ask the user for a name, phone number, and email. Display the required information I have a file
Using the work on the previous assignment, ask the user for a name, phone number, and email. Display the required information
I have a file NewNumber but it states an error code
Error: Main method not found in class Phone, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
I need ONE file using smartphone and new number to run phone.java
here is my code
import java.util.Scanner; public class NewNumber { public static void main(String[] args) { Scanner src = new Scanner(System.in); System.out.println("New number creation tool"); System.out.print("Enter name "); String name = src.next(); System.out.print("Enter phone number "); String phone = src.next(); System.out.print("Enter email "); String email = src.next(); SmartPhone sp = new SmartPhone(name, phone, email); System.out.print(sp); System.out.print("Telephone neighbor: " + sp.getTelephoneNeighbor()); } }
separate file smartphone
public class SmartPhone extends Phone { private String email; private String phone; public SmartPhone() { super(); email = "None"; } public SmartPhone(String name, String phone) { super(name, Long.parseLong(phone)); this.email = "None"; } public SmartPhone(String name, String phone, String email) { super(name, Long.parseLong(phone)); this.email = email; } public boolean hasPhoneNumber() { return !phone.equals("Not set"); } public String getAreaCode() { return phone.substring(0, 3); } public String getPrefix() { return phone.substring(3, 6); } public String getLineNumber() { return phone.substring(6); } public String toString() { return "Name: " + name + " " + "Phone: " + phone + " " + "Email: " + email + " "; } public String getTelephoneNeighbor() { if (phone == "Not set") { return "Cannot calculate phone number neighbor"; } else { String res = "("; res += phone.substring(0, 3) + ")"; res += phone.substring(3, 6) + "-"; res += Integer.parseInt(phone.substring(6, 10)) + 1; return res; } }
initial run file
public class Phone { protected String name; protected long number; public Phone() { this("None", -1); } public Phone(String name) { this(name, -1); } public Phone(String name, long number) { this.name = name; this.number = number; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started