Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

JAVA HELP I need one file code to display New number creation tool Enter name BobENTER Enter phone number 5552124567ENTER Enter email test@example.comENTER Name: Bob

JAVA HELP I need one file code to display

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

This is the code I have currently, it doesnt work

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

currently Im getting an error where

smartphone sp = new smartphone (name,phone,email) cannot be found

this is because I cant use the file that corresponds to this construct in my method

i receive a main method not found error when I use smartphone file

here is smartphone, I need the work from here to ask the user for a name phone number and email to display information

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

i only have this Phone.Java file to make my New Number display required output

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

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

BPR always involves automation. Group of answer choices True False

Answered: 1 week ago