IN JAVA PLEASE note: disregard the x in "gmxl". answers will not let me post the question. 9.2 Lab 17: Newsletter Subscrip

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

IN JAVA PLEASE note: disregard the x in "gmxl". answers will not let me post the question. 9.2 Lab 17: Newsletter Subscrip

Post by answerhappygod »

IN JAVA PLEASE
note: disregard the x in "gmxl". answers will not let me
post the question.
9.2 Lab 17: Newsletter Subscriptions
We write a program to enroll a users email addresses in a
newsletter subscription. Valid email addresses have specific
requirements, which we verify.
Lab Specifications
Example Output
If the inputs are:
the console/terminal looks like:
STARTER CODE TEMPLATE:
/**
* Manages newsletter subscriptions.
* @author
* CIS 36A, Lab 17
*/
import java.util.Scanner;
public class Newsletter {
/**
* Removes all blank spaces in front of and at
the end of a String Hint: use two
* while loops - one for the front of the
String, and one for the end of the
* String. Use substring to remove the blank
space from the String
*
* @param email the email address
* @return an email with no blank spaces at the
front or end of the String
*/
public static String cutSpace(String email)
{
// write one while loop
here
// write the
second while loop here
return
email;
}
/**
* Searches a String for an @ character
*
* @param email the String to search
* @return whether the String contains an
'@'
*/
public static boolean hasAt(String email)
{
// write a for loop here to
iterate through the String email
return false;
}
/**
* Uses a for loop to iterate through an array
of correct email extensions,
* comparing the last 4 characters in a String
parameter to each correct
* extension. Hint: If the extension matches the
last 4 chars in the parameter
* return true and return false only after
checking all extensions
*
* @param email the String, whose last 4 chars
is compared to each extension
* @return whether or not the last 4 chars match
one of the extensions
*/
public static boolean validExtension(String
email) {
// source:
https://en.wikipedia.org/wiki/List_of_I ... el_domains

String[] extensions = {
".com", ".net", ".org", ".edu", ".gov", ".mil" };
// write a for loop here to
iterate through the array extensions
return false;
}
/**
* Determines whether a String contains a
space
*
* @param email the String to search for a
space
* @return whether the String contains a
space
*/
public static boolean hasSpace(String email)
{
// Write a for loop here to
iterate through the String email
return false;
}
public static void main(String[]
args) {
Scanner input = new
Scanner(System.in);
int numEmails;
System.out.println("Welcome to our newsletter subscription
service!\n");
System.out.print("Enter the
number of emails to subscribe: ");
// check for input mismatch
exception with a while loop
numEmails =
input.nextInt();
// declare your
array of Strings here
// Write a for
loop here with if-else if-else if-else
// In each if and else-if
statement, call one of your methods
System.out.println("\nYou entered the following
emails:\n");
// print the array to the
console with a for loop
input.close();
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply