Answered step by step
Verified Expert Solution
Link Copied!

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 . New number creation

Using the work on the previous assignment, ask the user for a name, phone number, and email. Display the required information \.

New number creation tool Enter name BobENTER Enter phone number 5552124567ENTER Enter email test@example.comENTER Name: Bob Phone: 5552124567 Email: test@example.com Telephone neighbor: (555) 212-4568

I need ONE FILE using new number and phone to display this information

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()); } }

I must implement coding from SmartPhone into NewNumber, however I don't have excess to SmartPhone file when running the code to display the required output.

I do not have and cannot have access to this file, I can only use my previous work to make a new file that uses some or all this information.

if I use class Smartphone in my code I get this error in

NewNumber.java:14: error: cannot find symbol 

I think my error is here: SmartPhone sp = new

class 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; } }

Phone

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; } I get the same error every time I need New Number to run using only class phone.Java but the code needs to implement factors from Smartphone without using the entire code.

If I cant use smartphone.Java full code how can only use New Number to display the outcome with only Phone.java????

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

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago