Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help on JUST PART B of my lab assignment which is due in 3 hours. Provided below is my code for part A. Please

Need help on JUST PART B of my lab assignment which is due in 3 hours. Provided below is my code for part A. Please write in a very beginner/simple style coding for java for easy understanding. Thank you for your help!

image text in transcribed

image text in transcribed

My code for part A:

import java.util.Scanner;

public class Lab2 { public static void main(String[] args) { //declaring variable String name; int streetNumber; String streetName; String city; String state; int zip; String major; int studentId; Scanner sc=new Scanner(System.in);//scanner object to get uper input //asking user to enter data System.out.println("Enter name"); name=sc.nextLine(); System.out.println("Street number"); streetNumber=Integer.parseInt(sc.nextLine()); System.out.println("Street NAme"); streetName=sc.nextLine(); System.out.println("City"); city=sc.nextLine(); System.out.println("State"); state=sc.nextLine(); System.out.println("Zip"); zip=Integer.parseInt(sc.nextLine()); System.out.println("Major"); major=sc.nextLine(); //displaying data System.out.println("Student ID"); studentId=Integer.parseInt(sc.nextLine()); System.out.println("Student infomation:"); System.out.println("Name: "+name); System.out.println(streetNumber+","+streetName+" "+city+","+state+","+zip); System.out.println("Student Id: "+studentId); System.out.println("Major: "+major); }

}

-Lab 2-User Input & Documentation OVERVIEW You will practice instance variables (fields), user input, console output, and java documentation. Part A: User Input, Instance Variables and Console Output Part B: Adding Javadoc to code Part C: Magic Square Part A: User Input, Instance Variables (fields), and Console Output 1) Each instance variable is defined by its datatype and a unique name. Because instance variables are most often "things", we generally use nouns as instance variable names. Note that in Java the convention for variable names is what's known as camel case. That is, the first word of the variable identifier is all lower-case letters. If multiple words are used in the identifier, the first character of every word after the first is upper case (like the hump on a camel). For example, a variable to hold your first name might have an identifier like firstName. A variable for the street of your address might just be street because it's only one word. A variable to hold your favorite movie might be named myFavoriteMovie. The table below shows the instance variables you will be using: Instance Variable Description Java Datatype Name String Street Number Int Street Name String City String State String Zip Code Int College Major String 800 number Java Identifier name streetNumber streetName city state zip major studentId Int 2) Create a new project called Lab2. Make sure to create a main/driver class if one is not provided by your IDE 3) In your main source code file, declare all of the instance variables in the table above. 4) Prompt the user to enter the information that will be stored in each instance variable See https://www.w3schools.com/java/java user input.asp for user input. 5) Display to the console all of the information the user entered. Your output should look like: Student Information: Name: Geoffrey Grimaud Address: 555 House Lane Big City, AA 11111 Student Id: 800555555 Major: Computer Science 6) Once your program compiles without errors and you run it for the first time, you will see that you are unable to enter your street address. The program skips to the prompt for city. This occurs because nextInt() does not capture the new line and skips the next scanner code. To fix the problem, clear the buffer by using nextLine() immediately after each nextInt(). System.out.println("Enter your street number"); streetNumber = myObj.nextInt(); // Read user input myobj.nextLine(); Part B: Add Javadoc to code A cellphone service provider has three different subscription packages. Plan A: $29.95 per month 3GB of data provided. Additional data $10 per 1GB data Plan B: $49.95 per month 5GB of data provided. Additional data $8 per 1GB data Plan C: $69.95 per month with unlimited data provided. 1) Write a method cellphoneCost() that accomplishes the following requirements: It should prompt the user to enter the letter of the package the customer purchased (A, B or C) and the amount of data that was used. Calculate and display the total charges Calculate and display the amount of money Plan A customers would save if they purchased Plans B or C Calculate and display the amount of money Plan B customers would save if they purchased Plan If there are no savings, display a message that the customer has the most cost-efficient plan. 2) Add Java doc comments at the top of your cellPhoneCost () method. They should include A summary that describes the purpose of the method @author specifies the author of the method @param lists and describes each of the parameters in the parameter list (if any). @return describes the information that is returned to the calling statement (if any). 3) In NetBeans you can right-click the Src icon, click Tools, then click Analyze Javadoc. This will tell you if you need to add more information. 4) When you are done, generate the Javadoc. Check the method summary and the method details to ensure your comments were put into the Java Documentation correctly. Part C: Square Display 1) Write a method that prompts the user for a positive integer no greater than 15. The method should verify that a positive integer no greater than 15 was entered. It should then display a square on the screen using the character "X". The number entered will be the length of each side of the square. For example, if the user enter 5, the display should look like the following: XXXXX XXXXX XXXXX

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

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

1. How do most insects respire ?

Answered: 1 week ago

Question

Who is known as the father of the indian constitution?

Answered: 1 week ago

Question

1.explain evaporation ?

Answered: 1 week ago

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago