Question: /* * NOTE: This file does not require debugging * */ package debugmeone; import javax.swing.JFrame; public class DrawMe extends JFrame { public static void main(

/* * NOTE: This file does not require debugging * */

package debugmeone;

import javax.swing.JFrame;

public class DrawMe extends JFrame { public static void main( String args[] ) { // create frame for CirclesJPanel JFrame frame = new JFrame( "Draw Me" ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

DrawMePanel circlesJPanel = new DrawMePanel(); frame.add( circlesJPanel ); // add circlesJPanel to frame frame.setSize( 200, 250 ); // set frame size frame.setVisible( true ); // display frame } // end main }

*************************

/* * This small program draws 8 circles on a JPanel each of larger size as * it loops. Add the method required to draw the circles on the JPanel. */ package debugmeone;

import java.awt.Graphics; import javax.swing.JPanel;

public class DrawMePanel extends JPanel { for ( int topLeft = 0; topLeft < 80; topLeft += 10 ) { int radius = 160 - ( topLeft * 2 ); g.drawArc( topLeft + 10, topLeft + 25, radius, radius, 0, 360 ); } // end for }

--------------------------------------------------------------------------------------------------------------------------------------------------------------

"THE CASE OF THE SPLITTING PHONE NUMBER" * * write a "regular expression" that will * accept a phone number in the correct format. Regular expressions help in * matching strings. Page down to line 37 and provide the regular expression * as a string that will accept a phone number in the format: (999) 999-9999 * * VALID OUTPUT: (THIS IS WHAT YOU ARE GOING FOR!) * Please enter phone number: * (123) 678-0909 << NOTE THE FORMAT WITH PARANS AND SPACE * Area Code: 123 << AREA CODE SPLIT * Phone Number: 6780909 << PHONE NUMBER SPLIT - NO DASH * * INVALID OUTPUT: * Please enter phone number: * (123)5550909 << NOTE THE INPUT FORMAT IS INCORRECT * Invalid input. << ERROR MESSAGE */ import java.util.Scanner;

public class CaseOfTheSplittingPhoneNumber { public static void main( String args[] ) { Scanner scanner = new Scanner( System.in ); System.out.println( "Please enter phone number:" ); String phoneNumber = scanner.nextLine();

/////////////////////////////////////////////////////////////////////// // Provide, as a String, the regular expression that splitPhoneNumber // should be. /////////////////////////////////////////////////////////////////////// String splitPhoneNumber = ; // <<-- ADD YOUR REGULAR EXPRESSION HERE!! if ( !phoneNumber.matches( splitPhoneNumber ) ) { System.out.println( "Invalid input." ); System.exit( 1 ); }

String[] tokens = phoneNumber.split( "\\) " ); String areaCode = tokens[ 0 ].substring( 1 ); tokens = tokens[ 1 ].split( "-" ); String number = tokens[ 0 ] + tokens[ 1 ]; System.out.printf( "Area Code: %s Phone Number: %s ", areaCode, number ); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!