Questions
I am struggling with this java code Objectives: Your program will be graded according to the...

I am struggling with this java code

Objectives: Your program will be graded according to the rubric below. Please review each objective before submitting your work so you don’t lose points. 1. Create a new project and class in Eclipse and add the main method. (10 points)

2. Construct a Scanner to read input from the keyboard. (10 points)

3. Use the Scanner to read the name, number of balls, and yards per ball of a yarn type specified by a pattern. Prompt the user to input this data as shown in the example below, and store the data in variables. (15 points)

4. Use the Scanner to read the name and yards per ball of a substitute yarn. Prompt the user to input this data, and store the data in variables. (10 points)

5. Use conditional statements to check that each numerical input is a positive integer. Give the user one chance to correct each invalid input. Prompt the user to input a positive value as shown in the example. (15 points)

6. Calculate the number of substitute yarn balls. Use a method of the Math class to round up to the nearest full ball, and store the result in a variable. (20 points)

7. Print the number of substitute yarn balls to the console, matching the format of the example. (10 points)

8. Use meaningful variable names, consistent indentation, and whitespace (blank lines and spaces) to make your code readable. Add comments where appropriate to explain the overall steps of your program. (10 points)

In: Computer Science

Please discuss the design principles that guide the authors of instruction sets in making the right...

Please discuss the design principles that guide the authors of instruction sets in making the right balance. Provide examples of application of each of the three design principles while designing instruction sets.

In: Computer Science

Please type your answer, I will rate you well. This is about Threat Modeler when conducting...

Please type your answer, I will rate you well.

This is about Threat Modeler when conducting risk assessments.

  • What did you learn about threat modeling by examining the features of Threat Modeler?
  • Should software like Threat Modeler be used exclusively, or in addition to other threat modeling techniques?

In: Computer Science

mport java.util.Scanner; public class BankAccount { //available balance store static double availableBalance; // bills constants final...

mport java.util.Scanner;

public class BankAccount {

//available balance store

static double availableBalance;

// bills constants

final static int HUNDRED_DOLLAR_BILL = 100;

final static int TWENTY_DOLLAR_BILL = 20;

final static int TEN_DOLLAR_BILL = 10;

final static int FIVE_DOLLAR_BILL = 15;

final static int ONE_DOLLAR_BILL = 1;

public static void main(String[] args) {

System.out.print("Welcome to CS Bank\n");

System.out.print("To open a checking account,please provide us with the following information\n:" );

String fullname;

String ssn;

String street;

String city;

int zipCode;

Scanner input = new Scanner(System.in);

System.out.print("Please enter your full name:");

fullname = input.nextLine();

System.out.print("Please enter your street address:");

street = input.nextLine();

System.out.print("Please enter the city:");

city = input.nextLine();

System.out.print("Please nter the zipCode:");

zipCode= input.nextInt();

//zip_code enter must be 5 digit

while(zipCode <10000 || zipCode> 99999) {

System.out.println("You enter an invalid zip code.");

System.out.println("Zip code must be 5 digits.");

System.out.println("Re-enter your zip code.");

zipCode = input.nextInt();

}

input.nextLine();

//System.out.println();

System.out.print("Enter the SSN");

ssn = input.nextLine();

// loop until a valid SSN is not enter

while(!validateSSN(ssn)) {

System.out.println("That was an invalid ssn.");

System.out.println("Example of a valid SSN is: 144-30-1987");

System.out.print("Re-enter the SSN:");

ssn = input.nextLine();

}

System.out.println();

System.out.print("Enter the initial balance in USD:");

availableBalance =Double.parseDouble(input.nextLine());

while(availableBalance < 0) {

System.out.println("That was an invalid amount");

System.out.print("Please re-enter the initial balance in USD:");

availableBalance = Double.parseDouble(input.nextLine());

}

System.out.println();

deposit();

System.out.println();

withdraw();

System.out.println();

displayBills();

}

public static void deposit() {

double amountToDeposit;

Scanner input = new Scanner(System.in);

System.out.print("Enter the amount to deposit:");

amountToDeposit=Double.parseDouble(input.nextLine());

while(amountToDeposit<0) {

System.out.println("That was an invalid amount.");

System.out.print("Please re-enter the amount to deposit: $");

amountToDeposit = Double.parseDouble(input.nextLine());

}

availableBalance = availableBalance + amountToDeposit;

System.out.print("Amount deposited successfully\n");

System.out.println("Your final currentbalance is: $" + String.format("%.2f", availableBalance));

}

public static void withdraw() {

double amountToWithdraw;

Scanner input = new Scanner(System.in);

System.out.print("Enter the amount to withdraw:");

amountToWithdraw = Double.parseDouble(input.nextLine());

while(amountToWithdraw < 0) {

System.out.print("That was an invalid amount.");

System.out.print("Please re-enter the amount to withdraw:$");

amountToWithdraw = Double.parseDouble(input.nextLine());

}

if((availableBalance-amountToWithdraw)< 0) {

System.out.println("SERIOUS ERROR OCCURED");

System.out.println("You try to withdraw an amount more than the available balance");

System.out.print("Program is exiting....");

System.exit(-1);

}

availableBalance = availableBalance-amountToWithdraw;

System.out.println(" Amount withdraw successfully");

System.out.println("Your final account balance is:$ "+String.format("%.2f",availableBalance));

}

public static void displayBills() {

double balance = availableBalance;

int bill_100 = (int)(balance/HUNDRED_DOLLAR_BILL );

balance = balance-(bill_100*HUNDRED_DOLLAR_BILL);

int bill_20 = (int)(balance/TWENTY_DOLLAR_BILL);

balance = balance-(bill_20*TWENTY_DOLLAR_BILL);

int bill_10 = (int)(balance/TEN_DOLLAR_BILL);

balance = balance-(bill_10*TEN_DOLLAR_BILL);

int bill_5 = (int)(balance/FIVE_DOLLAR_BILL);

balance = balance-(bill_5*FIVE_DOLLAR_BILL);

int bill_1 = (int)balance;

if(bill_100 > 0)

System.out.println("Count of $100 Bill is" + bill_100);

if(bill_20 > 0)

System.out.println("Count of $20 Bill is" + bill_20);

if(bill_10 > 0)

System.out.println("Count of $10 Bill is" + bill_10 );

if(bill_5 > 0)

System.out.println("Count of $5 Bill is" + bill_5);

if(bill_1 > 0)

System.out.println("Count of $1 Bill is" + bill_1);

}

public static boolean validateSSN(String ssn) {

//split the ssn based on '-' as delimiter

String[] tokens =ssn.split("-");

if(tokens.length != 3)

return false;

else {

if(tokens[0].length() != 3)

return false;

else if(tokens[1].length() != 2)

return false;

else if(tokens[2].length() != 4)

return false;

else {

//loop for each token chars

for(int i = 0; i < tokens.length; i++) {

int len = tokens[i].length();

for(int j = 0; j < len; j++) {

if(tokens[i].charAt(j)< 'o' || tokens[i].charAt(j) >'9')

return false;

}

}

return true;

}

}

}

}

Someone please fix my java program I'm having hard properly validating SSN . And fix any problem if found. Thanks.

In: Computer Science

In java Write multiple if statements: If carYear is before 1967, print "Probably has few safety...

In java

Write multiple if statements:
If carYear is before 1967, print "Probably has few safety features." (without quotes).
If after 1971, print "Probably has head rests.".
If after 1991, print "Probably has anti-lock brakes.".
If after 2002, print "Probably has airbags.".
End each phrase with period and newline. Ex: carYear = 1995 prints:

Probably has head rests.
Probably has anti-lock brakes.

public class SafetyFeatures {
public static void main (String [] args) {
int carYear;

carYear = 1991;

*insert code here*

}
}

In: Computer Science

Question: You are hired to develop an automatic patient monitoring system for a home-bound patient. The...

Question: You are hired to develop an automatic patient monitoring system for a home-bound patient. The system is required to read out the patient’s heart rate and blood pressure and compare them against specified safe ranges. The system also has activity sensors to detect when the patient is exercising and adjust the safe ranges. In case an abnormality is detected, the system must alert a remote hospital. (Note that the measurements cannot be taken continuously, since heart rate is measured over a period of time, say 1 minute, and it takes time to inflate the blood-pressure cuff.) The system must also

(i) check that the analog devices for measuring the patient’s vital signs are working correctly and report failures to the hospital

(ii) alert the owner when the battery power is running low.

Enumerate and describe the requirements for the system-to-be.

In: Computer Science

*Please give the answers in pseudo code 1) Design an algorithm that will receive two integer...

*Please give the answers in pseudo code

1) Design an algorithm that will receive two integer items from a terminal operator, and display to the screen their sum, difference, product and quotient. Note that the quotient calculation (first integer divided by second integer) is only to be performed if the second integer does not equal zero.


2) Design an algorithm that will read two numbers and an integer code from the screen. The value of the integer code should be 1, 2, 3 or 4. If the value of the code is 1, compute the sum of the two numbers. If the code is 2, compute the difference (first minus second). If the code is 3, compute the product of the two numbers. If the code is 4, and the second number is not zero, compute the quotient (first divided by second). If the code is not equal to 1, 2, 3 or 4, display an error message. The program is then to display the two numbers, the integer code and the computed result to the screen.


3) Design an algorithm that will receive the weight of a parcel and determine the delivery charge for that parcel. Charges are calculated as follows:
Parcel weight (kg)
Cost per kg ($)
<2.5
$3.50 per kg
2.5-5 kg
$2.85 per kg
>5 kg
$2.45 per kg

In: Computer Science

1.Write an HTML footer element to that states: o“Copyright 2019. All rights reserved”, using the copyright...

1.Write an HTML footer element to that states:

o“Copyright 2019. All rights reserved”, using the copyright symbol

oThe company e-mail, [email protected] as an e-mail link

In: Computer Science

This code assigns the maximum of the values 3 and 5 to the int variable max...

This code assigns the maximum of the values 3 and 5 to the int variable max and outputs the result

int max;

// your code goes here

This code prompts the user for a single character and prints "true" if the character is a letter and "false" if it is not a letter

// your code goes here

In: Computer Science

Consider the following pseudo-code: /* Global memory area accessible by threads */ #define N 100 struct...

Consider the following pseudo-code:

/* Global memory area accessible by threads */
#define N 100
struct frame *emptyStack[N];
struct frame *displayQueue[N];
int main() {
  /*
  ** Initialise by allocating the memory for N frames
  ** And place the N frame addresses into the
  ** empty Stack array
  */
  Initialise();
  thread_t tid1, tid2;
  threadCreate(&tid1, GetFrame);
  threadCreate(&tid2, ShowFrame);
  sleep(300);
}
GetFrame() {
  struct frame *frame;
  struct frame local;
  while (1) {
    CameraGrab(&local);  /* get a frame from the camera store it in local */
    frame = Pop(); /* pop an empty-frame address from the empty stack */
    CopyFrame(&local, frame); /* copy data from the local frame to the frame address */
    Enqueue(frame); /* push the frame address to the display queue */
}
}
ShowFrame() {
  struct frame *frame;
  struct frame local;
  struct frame filtered;
  while (1) {
    frame=Dequeue(); /* pop the leading full frame from the full queue */
    CopyFrame(frame, &local); /* copy data to the local frame */
    Push(frame);          /* push the frame address to the empty stack */
    Solarise(&filtered, &local); /* Modify the image */
    VideoDisplay(&filtered);     /* display the image */
  }

}

This program creates two threads, one calls GetFrame(), which continually grabs frames from a camera, and the other thread callsShowFrame(), which continually displays the frames (after modification). When the program starts the emptyStack contains the addresses of N empty frames in memory.

The process runs for 5 minutes displaying the contents from the camera.

The procedures Pop() and Push() are maintaining the list of frame addresses on the empty stack. Pop() removes a frame memory address from the empty stack, and Push() adds a memory address to the empty stack.

The procedures Dequeue() and Enqueue() are maintaining the list of frame memory addresses in the display queue in display order. Dequeue() removes the memory address of the next frame to display from the display queue, and Enqueue() adds a memory address to the end of the display queue.

The stack and the queue are the same size, and are large enough to contain all available frame memory addresses.

  1. Without including synchronisation code problems will occur. Discuss what could potentially go wrong?

  2. Identify the critical sections in the above pseudo-code.

  3. Modify the above pseudo-code using semaphores only, to ensure that problems will not occur.

    Hint: this is a variation on the Producer-Consumer problem and will require similar semaphores.

In: Computer Science

Java Programing: Predefined mathematical methods that are part of the class Math in the package java.lang...

Java Programing:

Predefined mathematical methods that are part of the class Math in the package java.lang include those below.

method name

description

abs( m )

returns the absolute value of m

ceil( m )

rounds m to the smallest integer not less than m

floor( m )

rounds m to the largest integer not greater than m

max( m , n )

returns the larger of m and n

min( m , n )

returns the smaller of m and n

pow( m , n )

returns m raised to the power n

round( m )

returns a value which is the integer closest to m

sqrt( m )

returns a value which is the square root of m

Evaluate each of the following, which include Math predefined methods.

(1)       _____ Math.abs( 6.0 )              (2)       _____ Math.abs( - 6.0 )

(3)       _____ Math.ceil( 10.25 )           (4)       _____ Math.ceil( - 6.8 )

(5)       _____ Math.floor( - 5.1 )           (6)       _____ Math.floor( 7.9 )

(7)       _____ Math.pow( 5 , 2 )             (8)       _____ Math.pow( 2 , 5 )

(9)       _____ Math.max( 1.5 , 2 )           (10)     _____ Math. min( 3 , 0.5 )

(11)     _____ Math.min( 2 , 1.5 )           (12)     _____ Math. max( 0.5 , 3 )

(13)     _____ Math.sqrt( 16.0 )            (14)     _____ Math. round( 0.6 )

(15)     _____ Math.ceil( Math.pow( 3 , 0.5 ) )

(16)     _____ Math.floor( Math.pow( 1.5 , 2 ) )   

(17)     _____ Math.ceil( Math.floor( 3.5 ) )

(18)     _____ Math.min( Math.max( 3.0 , 2 ), 2.5)

(19)     _____ Math.max( Math.min( 2.0 , 3 ), 3.0)

(20)     _____ Math.sqrt( Math.pow( 2.0 , 3 ) )    

(21)     _____ Math.pow( Math.sqrt( 9 ) , 2 ) )

(22)     _____ Math.round( Math.max( 2.1 , 3.1 ) )

(23)     _____ Math.abs( Math.abs( 8.0 ) )

(24)     _____ Math.min( Math.abs( 1.5 , 2 ) )

(25)     _____ Math.ceil( Math.pow( 1 , 0.5 ) )

In: Computer Science

Task Intro: Password JAVA and JUnit5(UNIT TESTING) Write a method that checks a password. The rules...

Task Intro: Password JAVA and JUnit5(UNIT TESTING)

Write a method that checks a password. The rules for the password are:

- The password must be at least 10 characters.
- The password can only be numbers and letters.
- Password must have at least 3 numbers.
Write a test class(Junit5/Unit testing) that tests the checkPassword method.

Hint: You can (really should) use method from built-in String class:

public boolean matches(String regex)
to check that the current string matches a regular expression. For example, if the variable "password" is the string to be checked, so will the expression.
password.matches("(?:\\D*\\d){3,}.*") 

return true if the string contains at least 3 numbers. Regular expression "^ [a-zA-Z0-9] * $" can be used to check that the password contains only numbers and letters.

Let your solution consist of 4 methods:

checkPassword(string password) [only test this method]
checkPasswordLength(string password) [checkPassword help method]
checkPasswordForAlphanumerics(string password) [checkPassword help method]
checkPasswordForDigitCount(string password) [checkPassword help method]

Intro: Password Criteria

The code is structured and formatted
Your code uses the standard java formatting and naming standard, it is also nicely formatted with the right indentation etc.
Good and descriptive variable names
Your code uses good variable names that describe the damped function, such as "counter" instead of "abc".

The code is logical and understandable

Your code is structured in a logical way so it's easy to understand what you've done and how to solve the problem. It should be easy for others to understand what your code does and how it works.

The solution shows understanding of the problem
You show with your code that you have thought about and understood the problem. It is worth thinking about how you will solve the problem before you actually solve it
The code solves the problem
Your code manages to do what is required in the assignment text, and it does not do unnecessary things either.
Unit tests (Junit5) cover all common use cases
Unit tests for your code check all common ways it can be used, such as the isEven (int number) method being tested with even, odd, negative, and null, reverseString (String text) will be checked with regular string, empty string and zero object, etc.
The code uses Regex and built-in methods
Do not try to reinvent the wheel, it is possible to check the text string for digits with a while / for loop, but using regex and matching function is much easier. There are many websites that help you find regex for what you need, so use them.

So my problem is that I need to unit test (JUnit5) my code below (Feel free to change the code, to fit the assigment better)

import java.util.Scanner;
import java.util.regex.Pattern;

public class Password {
   public static void main(String[] args) {
       Password call = new Password();
      
   }
  
   void checkPassword() {
       Scanner x = new Scanner(System.in);
       System.out.println("Enter your password");
       String y = x.nextLine();
      
      
       Password n = new Password();
       boolean v1 = n.checkPasswordForAlpanumerics(y);
       boolean v2 = n.checkPasswordForDigitCount (y);
       boolean v3 = n.checkPasswordLength(y);
       if(v1== true && v2 == true && v3 ==true) {
           System.out.println("Your password is valdid");}
          
       }
      
       boolean checkPasswordLength (String x) {
           int checklen=x.length();
           if(checklen>=10) {
               return true;}
           else {
               System.out.println("enter atleast 10 charachers");
               return false; }}
      
       boolean checkPasswordForAlpanumerics (String x) {
           String b = "^ [a-zA-Z0-9] * $";
           boolean check=Pattern.matches(b, x);
           if(check==true) {
               return true;}
          
           else {
               System.out.println("Password must contain numbers and letters only");
               return false; }}
      
       boolean checkPasswordForDigitCount (String s) {
           int count = 0;
           for ( int i = 0;i<s.length();i++) {
               if (Character.isDigit(s.charAt(i))) {
                   count++;}}
           if(count>=3) {
               return true; }
           else {
               System.out.println("Your password must contain atleast 3 numbers");
               return false;}
          
                  
               }}
      
              
          

In: Computer Science

I need a masters research thesis topic on data science or data analysis. you may wish...

I need a masters research thesis topic on data science or data analysis. you may wish to add an outline. thanks

In: Computer Science

8.    Within the footer, place a link to auto-call the company line: 800-685-2298. Display the text:...

8.    Within the footer, place a link to auto-call the company line: 800-685-2298.
Display the text: “Call Today” as a text link.

In: Computer Science

class LLNode<T> { public T info; public LLNode<T> link; public LLNode(T i, LLNode<T> l) { //...

class LLNode<T> {

public T info;

public LLNode<T> link;

public LLNode(T i, LLNode<T> l) { // constructor

info=i;

link=l;

}

}

class CircularLinkedQueue<T> {

private LLNode<T> rear = null; // rear pointer

public boolean isEmpty() {

/*checks if the queue is empty */

}

public int size() {

/* returns the number of elements in the queue */

}

public void enQueue(T element) {

/* enqueue a new element */

}

public T deQueue() {

/* dequeue the front element */

}

public String toString() {

String str = new String();

/* concatenate elements to a String */

return str;

}

}

In: Computer Science