public class UserName 1/ The list of possible user names, based on a user's first and last names and initialized by the constructor private ArrayList possibles ; /* Constructs a UserName object as described in part (a). • Precondition: firstName and lastNane have length greater than a and contain only uppercase and lowercase letters. public UserName(String firstName, String lastName) {/" to be implemented in part (a) */) /** Returns true if arr contains name, and false otherwise. */ public boolean isused(String name, Strinell arr) [/" implementation not shown ) /* Removes strings from possibleNames that are found in usedNames as described in part (6) public void setAvailableUserNames(Strinel) usedNames) { 1 to be implemented in part (6) (a) Write the constructor for the UserName class. The constructor initializes and fills possibleNames with possible user names based on the firstName and lastName parameters. The possible user names are obtained by concatenating lastName with different substrings of firstName. The substrings begin with the first character of firstName and the lengths of the substrings take on all values from 1 to the length of firstName.

Answers

Answer 1

Answer: Provided in the explanation segment

Explanation:

CODE:-

import java.util.*;

class UserName{

  ArrayList<String> possibleNames;

  UserName(String firstName, String lastName){

      if(this.isValidName(firstName) && this.isValidName(lastName)){

          possibleNames = new ArrayList<String>();

          for(int i=1;i<firstName.length()+1;i++){

              possibleNames.add(lastName+firstName.substring(0,i));

          }  

      }else{

          System.out.println("firstName and lastName must contain letters only.");

      }

  }

  public boolean isUsed(String name, String[] arr){

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

          if(name.equals(arr[i]))

              return true;

      }

      return false;

  }

  public void setAvailableUserNames(String[] usedNames){

      String[] names = new String[this.possibleNames.size()];

      names = this.possibleNames.toArray(names);

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

          if(isUsed(usedNames[i],names)){

              int index = this.possibleNames.indexOf(usedNames[i]);

              this.possibleNames.remove(index);

              names = new String[this.possibleNames.size()];

              names = this.possibleNames.toArray(names);

          }

      }

  }

  public boolean isValidName(String str){

      if(str.length()==0) return false;

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

          if(str.charAt(i)<'a'||str.charAt(i)>'z' && (str.charAt(i)<'A' || str.charAt(i)>'Z'))

              return false;

      }

      return true;

  }

  public static void main(String[] args) {

      UserName person1 = new UserName("john","smith");

      System.out.println(person1.possibleNames);

      String[] used = {"harta","hartm","harty"};

      UserName person2 = new UserName("mary","hart");

      System.out.println("possibleNames before removing: "+person2.possibleNames);

      person2.setAvailableUserNames(used);

      System.out.println("possibleNames after removing: "+person2.possibleNames);

  }

}

cheers i hope this helped !!


Related Questions

2 x + y for x = 1 and y = 1​

Answers

Answer:

3

Explanation:

2*1+1

2+1

hope this helps

A MAC Frame format has a Preamble of 7 octet pattern in the form of alternating 1s and 0s used by a receiver to establish synchronization. Use a Manchester Encoding technique to describe the first octet of the signal pattern produced within the Preamble.

Answers

Answer:

The Manchester encoding to describe the first octet pattern signal within the preamble is 10101010

Explanation:.

Solution

Given that:

The first octet value of Preamble is 10101010

The Manchester encoding to outline or describe the first octet of the signal pattern produced or created within the preamble is 10101010

Note: Kindly find an attached image of the first octet signal pattern produced below.

After pushing the power switch of the PC to the ʺonʺ position, Bob, the PC repair person, realizes that the power-on lights found on the monitor and computer case do not light up and nothing displays on the screen. The first thing that Bob does is check the power plugs found on the back of the computer case and monitor. Bobʹs actions best illustrate the use ________ in solving a problem.
1. Professional and technical training
2. Logic3. Communication
4 .Beginnerʹs luck

Answers

Answer:

2. Logic

Explanation:

We all know that for the PC to come on, there must be a power input, this means that if the PC does not power on, then there is probably no power input into the PC. It is only logical for Bob to check if the PC is properly connected first when the power-on lights did not come on. People with no technical training should be able to apply this simple logic too.

Suggest how you would go about validating a password protection system for an application that you have developed. Explain the function of any tools that you think may be useful.

Answers

Um idk just answering so I can get a answer for mine

Write a program that prompts the user to enter three cities and displays them in ascending order. Here is a sample run: Enter the first city: Chicago Enter the second city: Los Angeles Enter the third city: Atlanta The three cities in alphabetical order are Atlanta Chicago Los Angeles

Answers

Answer:

import java.util.Scanner;

public class SortStrings3 {

   public static void main(String args[]){

       Scanner scanner = new Scanner(System.in);

       String str1, str2, str3;

       System.out.print("Enter the first city: ");

       str1 = scanner.nextLine();

       System.out.print("Enter the second city: ");

       str2 = scanner.nextLine();

       System.out.print("Enter the third city: ");

       str3 = scanner.nextLine();

       System.out.print("The three cities in alphabetical order are ");

       if(str1.compareTo(str2) < 0 && str1.compareTo(str3) < 0){

           System.out.print(str1+" ");

           if(str2.compareTo(str3) < 0){

               System.out.print(str2+" ");

               System.out.println(str3);

           }

           else {

               System.out.print(str3+" ");

               System.out.println(str2);

           }

       }

       else if(str2.compareTo(str1) < 0 && str2.compareTo(str3) < 0){

           System.out.print(str2+" ");

           if(str1.compareTo(str3) < 0){

               System.out.print(str1+" ");

               System.out.println(str3);

           }

           else {

               System.out.print(str3+" ");

               System.out.println(str1);

           }

       }

       else{

           System.out.print(str3+" ");

           if(str1.compareTo(str2) < 0){

               System.out.print(str1+" ");

               System.out.println(str2);

           }

           else {

               System.out.print(str2+" ");

               System.out.println(str1);

           }

       }

   }

}

EXPLANATION:

Okay, we are given that a program should be written which will make user to enter three cities namely Atlanta, Chicago and Los Angeles (which should be done in ascending  alphabetical order).

So, we will be writting the code or program with a programming language known as JAVA(JUST ANOTHER VIRTUAL ACCELERATOR).

We will make use of java to write this program because Java can be used in Loading code, verifying codes and executing codes on a single or multiple servers.

The code or program can be seen in the attached file/document. Kindly check it.

What color model should Joe use if he will be using an offset printing press?

Answers

Answer:

The color model used for an offset printing press should involve cyan, magenta, yellow and black. The combination of this creates a black color.

Offset printing doesn’t involve the direct contact of the ink with the paper. The ink usually comes in contact first with a rubber cylinder after which the cylinder makes the necessary imprints on the paper.

when searching fora an image on your computer, you should look for a file with what extensions

Answers

Answer:png, jpeg, jpg, hevc, raw, bmp, png, webp

Explanation:

Just look for all the Image file formats

The skip_elements function returns a list containing every other element from an input list, starting with the first element. Complete this function to do that, using the for loop to iterate through the input list.

Answers

Answer:

Following are code that we fill in the given in the given question

if i %2==0:# check the condition

new_list.append(elements[i])# append the list  

return new_list # return the new_list

Explanation:

Missing Information :

def skip_elements(elements):# function

new_list=[]# Declared the new list

i=0  #variable declaration

for i in range(len(elements)): #iterating over the loop  

if ---------# filtering out even places elements in the list

--------------# appending the list

return -------- # returning the new_list

print(skip_elements(['a','b','c','d','e','f','g'])) #display

Following are the description of the code:

In this we declared a function skip_elements .In this function we pass the parameter into them .After that we declared the new_list array.Declared the variable "i" that are initialized with the 0 value .Iterating over the for loop and this loop we check the condition in the if condition.The if condition executed when the index is even .The statement inside the if condition we will appending the list and returning the list item .Finally we print the even number of index list .

Assume the following variable definition appears in a program:
double number = 12.3456;
Write a cout statement that uses the setprecision manipulator and the fixed manipulator to display the number variable rounded to 2 digits after the decimal point. (Assume that the program includes the necessary header file for the manipulators.)

Answers

Answer:

cout << setprecision(2)<< fixed << number;

Explanation:

The above statement returns 12.35 as output

Though, the statement can be split to multiple statements; but the question requires the use of a cout statement.

The statement starts by setting precision to 2 using setprecision(2)

This is immediately followed by the fixed manipulator;

The essence of the fixed manipulator is to ensure that the number returns 2 digits after the decimal point;

Using only setprecision(2) in the cout statement will on return the 2 digits (12) before the decimal point.

The fixed manipulator is then followed by the variable to be printed.

See code snippet below

#include <iostream>  

#include <iomanip>

using namespace std;  

int main()  

{  

// Initializing the double value

double number = 12.3456;  

//Print  result

cout << setprecision(2)<< fixed << number;  

return 0;  

}  

Given parameters b and h which stand for the base and the height of an isosceles triangle (i.e., a triangle that has two equal sides), write a C program that calculates: The area of the triangle; The perimeter of the triangle; And The volume of the cone formed by spinning the triangle around the line h The program must prompt the user to enter b and h (both of type double) The program must define and use the following three functions: Calc Area (base, height) //calculates and returns the area of the triangle Calc Perimeter (base, height) //calculates and returns the perimeter Calc Volume(base, height) //calculates and returns the volume

Answers

Answer:

The area of the triangle is calculated as thus:

[tex]Area = 0.5 * b * h[/tex]

To calculate the perimeter of the triangle, the measurement of the slant height has to be derived;

Let s represent the slant height;

Dividing the triangle into 2 gives a right angled triangle;

The slant height, s is calculated using Pythagoras theorem as thus

[tex]s = \sqrt{b^2 + h^2}[/tex]

The perimeter of the triangle is then calculated as thus;

[tex]Perimeter = s + s + b[/tex]

[tex]Perimeter = \sqrt{b^2 + h^2} + \sqrt{b^2 + h^2} +b[/tex]

[tex]Perimeter = 2\sqrt{b^2 + h^2} + b[/tex]

For the volume of the cone,

when the triangle is spin, the base of the triangle forms the diameter of the cone;

[tex]Volume = \frac{1}{3} \pi * r^2 * h[/tex]

Where [tex]r = \frac{1}{2} * diameter[/tex]

So, [tex]r = \frac{1}{2}b[/tex]

So, [tex]Volume = \frac{1}{3} \pi * (\frac{b}{2})^2 * h[/tex]

Base on the above illustrations, the program is as follows;

#include<iostream>

#include<cmath>

using namespace std;

void CalcArea(double b, double h)

{

//Calculate Area

double Area = 0.5 * b * h;

//Print Area

cout<<"Area = "<<Area<<endl;

}

void CalcPerimeter(double b, double h)

{

//Calculate Perimeter

double Perimeter = 2 * sqrt(pow(h,2)+pow((0.5 * b),2)) + b;

//Print Perimeter

cout<<"Perimeter = "<<Perimeter<<endl;

}

void CalcVolume(double b, double h)

{

//Calculate Volume

double Volume = (1.0/3.0) * (22.0/7.0) * pow((0.5 * b),2) * h;

//Print Volume

cout<<"Volume = "<<Volume<<endl;

}

int main()

{

double b, h;

//Prompt User for input

cout<<"Base: ";

cin>>b;

cout<<"Height: ";

cin>>h;

//Call CalcVolume function

CalcVolume(b,h);

//Call CalcArea function

CalcArea(b,h);

//Call CalcPerimeter function

CalcPerimeter(b,h);

 

return 0;

}

Canadian Tire is one of Canada’s largest companies. They operate four large distribution centers service over 470 tire retail outlets. They recently installed a Yard Management System (YMS), which they have integrated with their Warehouse Management Systems (WMS) and Transport Management System (TMS) systems. Their expectation was improved performance in over-the-road transportation equipment utilization, driver productivity, and warehouse dock/door utilization. As a relatively new logistics employee, you have been asked to develop an evaluation system to measure operational productivity improvement. While management does not want a financial impact evaluation, they are interested in developing benchmarks to measure initial and sustainable productivity improvement. You have the job-how would you proceed?

Answers

Answer: Provided in the explanation section

Explanation:

A YMS acts an interface between a WMS and TMS.The evaluation system with the key performance indicators are mentioned in the table below.

NOTE: The analysis follows in this order given below

MetricDescriptionComments

Metric 1

Trailer utilization

Description :This captures the status of the trailer whether it is in the yard or is in transit

Comments : Helps in measuring the trailer productivity on a daily ,weekly or monthly basis

Metric 2

Driver utilization

Description : This captures the status of the driver whether the driver is in the yard or is in transit

Comments : Helps in measuring the driver productivity on a periodic basis

Metric 3

Trailer sequence

Description : This captures the order of movement of trailers in the yard on a given day, week or month

Comments : Helps in measuring the order fulfilment efficiency i.e. whether the priority orders have been serviced first or not

Metric 4

Total time in yard

Description : This captures the time spent by the trailer in the yard from the time it enters and leaves the yard

Comments : This helps in measuring the time taken to fulfill a particular request

⇒ Capturing these metrics need inputs from both WMS and TMS, and also the trailers need to have RFID tags attached to them.Then compare these performance metrics with the ones prior to the deployment of YMS to identify the percent gains in the overall operational productivity.

cheers i hope this helped !!

Richard Palm is the accounting clerk of Olive Limited. He uses the source documents such as purchase orders, sales invoices and suppliers’ invoices to prepare journal vouchers for general ledger entries. Each day he posts the journal vouchers to the general ledger and the related subsidiary ledgers. At the end of each month, he reconciles the subsidiary accounts to their control accounts in the general ledger to ensure they balance.
Discuss the internal control weaknesses and risks associated with the above process. (maximum 300 words)

Answers

Answer:

Lack of segregation of duties

Explanation:

Internal Controls are set of rules and guidelines that are followed to ensure effectiveness of business operations. The main risk in the business is weak internal controls. There are some organizations with strong internal controls but implementation of such controls is a challenge for organizations. There are human errors, IT security risks, fraud and compliance risk.

The risks associated with Olive limited is that there is no segregation of duties, Richard Palm is preparing journal vouchers, posts the journal vouchers and reconciles the balance himself. If he makes an error in recording a transaction there is no one who reviews his work and can identify an error. Also if Richard is involved in a fraud and collaborates with purchase department or sales department staff, he can pass a transaction without any supervision.

An exact solution to the bin packing optimization problem can be found using 0-1 integer programming (IP) see the format on the Wikipedia page.
Write an integer program for each of the following instances of bin packing and solve with the software of your choice. Submit a copy of the code and interpret the results.
a) Six items S = { 4, 4, 4, 6, 6, 6} and bin capacity of 10
b) Five items S = { 20, 10, 15, 10, 5} and bin capacity of 20

Answers

sflpawkfowakfpowja0ifjhnaw0i

The goal for me is that I need to identify the objects needed for the UNO card game and the actions that those objects perform, rather than how the objects are suppose to actually be represented. Write a document that includes an ADT (abstract data type) for each object needed in my program. This is a partial ADT for the UnoCard class.
//get the color of the car
+getColor(): String
//set the color of the card
+setColor(color : String):void
//get the value of the card
+getValue(): int
//set the value of the card
+getValue(val : int): void
//return true if card has same value or
//same color as the card
//return false otherwise
+isMatch(card: UnoCard): boolean
The standard UNO card must be able to report both its color and value, and, when given another card, tell whether or not it is a "match.

Answers

Answer:

Explanation:

//Java program

class UnoCard{

  private String color;

  private int value;

 

  public UnoCard(String color , int val) {

      this.color = color;

      value = val;

  }

  public String getColor() {

      return color;

  }

  //set the color of the card

  public void setColor(String color ) {

      this.color = color;

  }

  //get the value of the card

  public int getValue() {

      return value;

  }

  //set the value of the card

  public void setValue(int val) {

      value = val;

  }

  //return true if card has same value or

  //same color as the card

  //return false otherwise

  public boolean isMatch(UnoCard card) {

      return (this.value==card.value)||(this.color==card.color);

  }

}

public class Card {

  public static void main(String args[]) {

      UnoCard card1 = new UnoCard("Red",10);

      UnoCard card2 = new UnoCard("Green",10);

      UnoCard card3 = new UnoCard("Blue",15);

     

      if(card1.isMatch(card2))System.out.println("Match");

      else System.out.println("No Match");

     

      if(card2.isMatch(card3))System.out.println("Match");

      else System.out.println("No Match");

  }

}

2-3 Calculating the Body Mass Index (BMI). (Programming Exercise 2.14) Body Mass Index is a measure of health based on your weight. It can be calculated by taking your weight in kilograms and dividing by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note: One pound is 0.45359237 kilograms and one inch is 0.0254 meters. Hint: Convert the pounds entered into kilograms also convert the height in inches into meters Example: If you entered in pounds your weight as 95.5 and your height as 50 inches then the calculated BMI is 26.8573 FYI: BMI < 18.5 is underweight BMI >

Answers

Answer:

weight = float(input("Enter your weight in pounds: "))

height = float(input("Enter your height in inches: "))

weight = weight * 0.45359237

height = height * 0.0254

bmi = weight / (height * height)

print("Your BMI is: %.4f" % bmi)

Explanation:

*The code is written in Python.

Ask the user to enter weight in pounds and height in inches

Convert the weight into kilograms and height into meters using given conversion rates

Calculate the BMI using given formula

Print the BMI

What are two key elements of describing the environment?​ a. ​ Communication protocols and security methods b. ​ External systems and technology architecture c. Programming language and operating system environment d. ​ Hardware configuration and DBMS’s

Answers

Answer:

B. External systems and technology architecture.

Explanation:

In such environment, you have to know what external systems are in place so have proper communication with External Systems whether be in message format or web/networks, Communication protocols, Security methods, Error detection and recovery,

Additionally, it consits of technology architecture so conforming to an existing technology architecture helps us discover and describe existing architecture

The two elements that describe the environment are external systems and technology architecture. Thus, the correct option for this question is B.

What is an Environment?

In computer and technology, the environment may be defined as anything which is present in the surrounding of computer and network connection. It significantly includes various protocols and their characteristics.

According to the environment of the computer, external systems are remarkably assisting in the proper communication, protocols, Security methods, Error detection, and recovery. It creates a supportive environment for the user. Apart from this, it also consists of technology architecture which confirms the process of existing technological perspectives.

Therefore, the two elements that describe the environment are external systems and technology architecture. Thus, the correct option for this question is B.

To learn more about Technology architecture, refer to the link:

https://brainly.com/question/15243421

#SPJ2

PROSZĘ O PILNĄ ODPOWIEDŹ
Zapisz algorytmy w postaci listy kroków:

1. algorytm mycia rąk

2. algorytm przejścia przez jezdnię

Przedstaw w postaci schematu blokowego:

1. Algorytm obliczania pola i obwodu prostokąta

2. Algorytm obliczania prędkości średniej pojazdu

Answers

Answer:

Kroki i algorytmy są opisane i załączone w poniższych akapitach

Explanation:

1. algorytm mycia rąk

za. Iść do ręki była umywalka

b. Włącz kran

do. Przenieś ręce pod wodę

 dopóki nie zostanie przemoczony

re. Weź mydło

mi. Nanieś mydło na obie ręce

fa. Zwróć mydło

sol. Umieść dłonie pod bieżącą wodą z kranu na 2 sekundy

h. Złóż dłonie razem i potrzyj

ja. Przetrzyj jedną rękę dłonią drugiej

jot. Zablokuj palce i potrzyj je o siebie

l. Kciukami potrzyj obszar paznokci palców obu rąk

m. Pocieraj opuszki palców dłoni

n. Przyłóż kciuk i koniec nadgarstka kumplami i potrzyj

o. Spłucz całe mydło z rąk

2. algorytm przekraczania drogi

za. Obserwuj i planuj

ja. Dotrzyj do bezpiecznego miejsca do przejścia (najlepiej przejścia dla pieszych lub sygnalizacji świetlnej lub tam, gdzie jest dozorca ruchu) i zatrzymaj się tam

ii. Jeśli powyższe nie jest możliwe, poszukaj miejsca, w którym można wyraźnie zobaczyć wszystkie nadjeżdżające pojazdy i gdzie mogą cię zobaczyć

b. Zatrzymać

ja. Odsuń się trochę od krawędzi drogi na chodniku

ii. Cierpliwie rozejrzyj się, aby upewnić się, że jesteś w bezpiecznym miejscu

do. Patrz i słuchaj

i. Spójrz i nasłuchuj ruchu we wszystkich kierunkach

re. Pozostań na miejscu, dopóki nie będzie można bezpiecznie przejść

ja. Cierpliwie pozwalaj na ruch uliczny

ii. Przejdź przez jezdnię, gdy jest przerwa w ruchu, dzięki czemu jest wystarczająco dużo czasu, aby przejść szybciej

iii. Przejdź tylko wtedy, gdy masz pewność, że nie nadjeżdżają żadne pojazdy

mi. Patrz dalej i słuchaj

ja. Gdy nie ma nadjeżdżających pojazdów, a następnie przejeżdżasz przez ulicę, upewnij się, że cały czas szukasz ruchu (pojazdów)

1. Algorytm obliczania pola i obwodu prostokąta

W załączeniu wymagany schemat blokowy

2. Algorytm obliczania średniej prędkości pojazdu

W załączeniu wymagany schemat blokowy

is co2+4h2--> ch4 + 2h2o a combustion​

Answers

Answer:

No its not a combustion its a formation.

Explanation:

building relationship during your carrer exploration is called

Answers

Answer:

Building relationships during your career exploration is called networking.

Finish and test the following two functions append and merge in the skeleton file:
(1) function int* append(int*,int,int*,int); which accepts two dynamic arrays and return a new array by appending the second array to the first array.
(2) function int* merge(int*,int,int*,int); which accepts two sorted arrays and returns a new merged sorted array.
#include
using namespace std;
int* append(int*,int,int*,int);
int* merge(int*,int,int*,int);
void print(int*,int);
int main()
{ int a[] = {11,33,55,77,99};
int b[] = {22,44,66,88};
print(a,5);
print(b,4);
int* c = append(a,5,b,4); // c points to the appended array=
print(c,9);
int* d = merge(a,5,b,4);
print(d,9);
}
void print(int* a, int n)
{ cout << "{" << a[0];
for (int i=1; i cout << "," << a[i];
cout << "}\n"; }
int* append(int* a, int m, int* b, int n)
{
// wru=ite your codes in the text fields
}
int* merge(int* a, int m, int* b, int n)
{
// wru=ite your codes in the text fields
}

Answers

Answer:

Explanation:

#include <iostream>

using namespace std;

int* append(int*,int,int*,int);

int* merge(int*,int,int*,int);

void print(int*,int);

int main()

{ int a[] = {11,33,55,77,99};

int b[] = {22,44,66,88};

print(a,5);

print(b,4);

int* c = append(a,5,b,4); // c points to the appended array=

print(c,9);

int* d = merge(a,5,b,4);

print(d,9);

}

void print(int* a, int n)

{ cout << "{" << a[0];

for (int i=1; i<n; i++)

cout << "," << a[i];

cout << "}\n";

}

int* append(int* a, int m, int* b, int n)

{

int * p= (int *)malloc(sizeof(int)*(m+n));

int i,index=0;

for(i=0;i<m;i++)

p[index++]=a[i];

for(i=0;i<n;i++)

p[index++]=b[i];

return p;

}

int* merge(int* a, int m, int* b, int n)

{

int i, j, k;

j = k = 0;

int *mergeRes = (int *)malloc(sizeof(int)*(m+n));

for (i = 0; i < m + n;) {

if (j < m && k < n) {

if (a[j] < b[k]) {

mergeRes[i] = a[j];

j++;

}

else {

mergeRes[i] = b[k];

k++;

}

i++;

}

// copying remaining elements from the b

else if (j == m) {

for (; i < m + n;) {

mergeRes[i] = b[k];

k++;

i++;

}

}

// copying remaining elements from the a

else {

for (; i < m + n;) {

mergeRes[i] = a[j];

j++;

i++;

}

}

}

return mergeRes;

}

Write a method that computes the sum of the digits in an integer. Use the following method header: public static int sumDigits(long n) For example, sumDigits(234) returns 9 the result of 2 3 4. (Hint: Use the % operator to extract digits, and the / operator to remove the extracted digit. For instance, to extract 4 from 234, use 234 % 10, which is 4. To remove 4 from 234, use 234 / 10, which is 23. Use a loop to repeatedly extract and remove the digit until all the digits are extracted.

Answers

Answer:

The java program for the given scenario is shown below.

import java.util.*;

import java.lang.*;

public class Test

{

   //variables to hold the number, digits and sum of the digits

   //variable to hold number is assigned any random value

   static long num=123;

   static int sum=0;

   static int digit;

   static int s;

   //method to add digits of a number

   public static int sumDigits(long n)

   { do

       {

           digit=(int) (n%10);

           sum=sum+digit;

           n=n/10;

       }while(n>0);

       return sum;

   }

public static void main(String[] args) {

    s = sumDigits(num);

 System.out.println("The sum of the digits of "+num+ " is "+s);  }

}

OUTPUT

The sum of the digits of 123 is 6

Explanation:

1. The variables to hold the number is declared as long and initialized.

2. The variables to store the digits of the number and the sum of the digits are declared as integer. The variable, sum, is initialized to 0.

3. The method, sumDigits(), is defined which takes a long parameter and returns an integer value. The method takes the number as a parameter and returns the sum of its digits.

4. Inside method, sumDigits(), inside the do-while loop, the sum of the digits of the parameter is computed.

5. Inside main(), the method, sumDigits(), is called. The integer value returned by this method is stored in another integer variable, s.

6. The sum of the digits is then displayed to the console.

7. All the variables are declared outside main() and at the class level and hence declared static. The method, sumDigits(), is also declared static since it is to be called inside main().

8. In java, the whole code is written inside a class since java is a purely object-oriented language.

9. In this program, object of the class is not created since only a single class is involved having main() method.

10. The program can be tested for any value of the variable, num.

11. The file is saved as Test.java, where Test is the name of the class having main() method.

In this scenario, two friends are eating dinner at a restaurant. The bill comes in the amount of 47.28 dollars. The friends decide to split the bill evenly between them, after adding 15% tip for the service. Calculate the tip, the total amount to pay, and each friend's share, then output a message saying "Each person needs to pay: " followed by the resulting number.

Answers

Answer:

The java program for the given scenario is as follows.

import java.util.*;

import java.lang.*;

public class Main

{

   //variables for bill and tip declared and initialized

   static double bill=47.28, tip=0.15;

   //variables for total bill and share declared

   static double total, share1;

public static void main(String[] args) {

    double total_tip= (bill*tip);

    //total bill computed

    total = bill + total_tip;

    //share of each friend computed

    share1 = total/2;

    System.out.printf("Each person needs to pay: $%.2f", share1);  

}

}

Explanation:

1. The variables to hold the bill and tip percent are declared as double and initialized with the given values.

static double bill=47.28, tip=0.15;

2. The variables to hold the values of total bill amount and total tip are declared as double.

3. All the variables are declared outside main() and at class level, hence declared as static.

4. Inside main(), the values of total tip, total bill and share of each person are computed as shown.

double total_tip= (bill*tip);

total = bill + total_tip;

share1 = total/2;

5. The share of each person is displayed to the user. The value is displayed with only two decimal places which is assured by %.2f format modifier. The number of decimal places required can be changed by changing the number, i.e. 2. This format is used with printf() and not with println() method.

System.out.printf("Each person needs to pay: $%.2f", share1);  

6. The program is not designed to take any user input.

7. The program can be tested for any value of bill and tip percent.

8. The whole code is put inside a class since java is a purely object-oriented language.

9. Only variables can be declared outside method, the logic is put inside a method in a purely object-oriented language.

10. As shown, the logic is put inside the main() method and only variables are declared outside the method.

11. Due to simplicity, the program consists of only one class.

12. The output is attached.

Answer:

bill =  47.28

tip = bill *.15

total = bill + tip

share = total

print( "Each person needs to pay: "+str(share) )

Explanation:

Program: ASCII art (Python 3)1) Output this tree. 2) Below the tree (with two blank lines), output this cat. (3 pts) /\ /\ o o = = --- Hint: A backslash \ in a string acts as an escape character, such as with a newline \n. So, to print an actual backslash, escape that backslash by prepending another backslash. Ex: The following prints a single backslash: System.out.println("\\");

Answers

The correct format for the output this tree is shown below:

(1) Output this tree

    ×

  ×××

×××××

×××××××

  ×××

(2) The correct format for the Below the tree is shown below:

Below the tree (with two blank lines), output this cat. (3 pts)

  / \        / \

     o     o

 =           =

   -   -   -

Answer:

Explanation:

We are given an Hint that:

A backslash \ in a string acts as an escape character, such as with a newline \n. So, to print an actual backslash, escape that backslash by prepending another backslash.

An Example : The following prints a single backslash: System.out.println("\\");

The main objective here is to use a Java code to interpret the above  (1) Output this tree and  (2) Below the tree.

So Using a Java code to interpret the Program: ASCII art ; we have:

public class AsciiArt {

  public static void main(String[] args) {

      // TODO Auto-generated method stub

 

      //Draw Tree

    System.out.println(" *");

      System.out.println(" ***");

      System.out.println(" *****");

      System.out.println("*******");

      System.out.println(" ***");

      //output cat

      System.out.println();

      System.out.println("/\\\t/\\");

      System.out.println(" o o");

      System.out.println(" = =")

      System.out.println(" ---");

  }

OUTPUT:

SEE THE ATTACHED FILE BELOW.

The program is a sequential program, and does not require loops and conditional statements.

See attachment for the complete program written in Python, where comments are used as explanation

Read more about Python programs at:

https://brainly.com/question/16397886

What are some ways technology has changed the way people live

Answers

Answer:

Multiple ways.

Explanation:

Here are some examples. Modern people relay on technology alot! It shapes our lives. Like now you can order something without moving from you place using your smartphone. When you need a spare part for a lego for example you can now just 3D print it without buying another one. See plenty of ways. Looks around you and find more examples.

Suppose two computers (A & B) are directly connected through Ethernet cable. A is sending data to B, Sketch the waveform produced by A when “$” is sent. Also mention the OSI layer that is responsible for this.

Answers

Answer:

Physical / Data link layer

Explanation:

If two computers (A & B) are directly connected through Ethernet cable. A is sending data to B, the data would be transmitted if the network is clear but if the network is not clear, the transmission would wait until the network is clear.

The Open Systems Interconnection model (OSI model) has seven layers each with its own function.

The physical layer is the first layer responsible for data transmission over a physical link. The data packets are converted to signals over a transmission media like ethernet cable.

The data link layer is the second layer in the OSI layer responsible for transmission of data packets between nodes in a network. It also provides a way of detecting errors and correcting this errors produced as a result of data transmission.

The OSI is reference/conceptual model and accordingly multiple practical models (such as TCP/IP, AppleTALK, etc) exits. Which fundamental functionalities necessarily needs to considered while implementing any network model?

Answers

Answer:

The fundamental functionalities necessarily needs to considered while implementing any network model are (1) Scalability, (2)The quality of service (3) Fault tolerance (4) Security.

Explanation:

Solution:

Network must help a wide area of applications and administrations, just just as work over various sorts of links and devices that make up the physical infrastructure. The term network refers to the innovations that help the infrastructure and the customized administrations and rules, or protocols, that move messages over the network.

The following are some  fundamental functionalities necessarily needs to considered while implementing any network model which is stated below:

(1) Scalability :

A huge number of users and service providers connect with the Internet every week. All together for the Internet to help this fast measure of development, it must be scalable.

A scalable network can extend rapidly to help new clients and applications without influencing the performance of the administration being conveyed to existing clients.  

(2)Quality of Service :

Networks must provide predictable, quantifiable, and, now and again, ensured administrations.  

Networks also need mechanisms to carry on congested network traffic. Network bandwidth is the estimate of the data-transfer size of the network. As such, what amount of data can be transmitted inside a particular measure of time? Network data transfer capacity is estimated in the quantity of bits that can be transmitted in a solitary second, or bits every second (bps).  

(3) Fault Tolerance :

The Internet is consistently accessible to the a huge number of users who depend on it. This requires a network design that is worked to be fault tolerant.

A fault-tolerant network is one that constrains the impact of a failure, with the goal that the least number of devices are influenced by it. It is likewise worked in a manner that empowers fast recuperation when such a failure happens.

Faults-tolerant networks rely upon various ways between the source and destination of a message. On the off chance that one way comes up short, the messages can be immediately sent over an alternate connection.

(4) Security:  

The Internet has advanced from a firmly controlled inter network of instructive and government associations to a generally open methods for transmission of business and individual interchanges.

Subsequently, the security necessities of the network have changed. The network infrastructure, the system administrations, and the information contained on arrange appended gadgets are vital individual and business resources. Bargaining the respectability of these benefits could have genuine outcomes.

Which of the following is the final step in the problem-solving process?

Answers

Explanation:

Evaluating the solution is the last step of the problem solving process.

Social engineering attacks can be carried out:______.
a. only through physical proximity, such as shoulder surfing.
b. remotely by highly sophisticated means and subject matter experts (SMEs).
c. only for fun, they don't give any useful information to the attacker, except may be by entering a building without an ID or something such.
d. via password cracking software, such as Rainbow trees.

Answers

The answer most likely B NOT SURE )

lan is working on a project report that will go through multiple rounds of
revisions. He decides to establish a file labeling system to help keep track of
the different versions. He labels the original document
ProjectReport_v1.docx. How should he label the next version of the
document?
A. ProjectReport_revised.docx
B. ProjectReport_v1_v2.docx
C. Report_v2.docx
D. ProjectReport_v2.docx

Answers

Answer:It’s D

Explanation:

APEVX

The label of the next version of the document can probably be ProjectReport_v2.docx. The correct option is D.

What is a document?

A document's purpose is to enable the transmission of information from its author to its readers.

It is the author's responsibility to design the document so that the information contained within it can be interpreted correctly and efficiently. To accomplish this, the author can employ a variety of stylistic tools.

Documentation can be of two main types namely, products and processes. Product documentation describes the product under development and provides instructions on how to use it.

A document file name is the name given to a document's electronic file copy.

The file name of the document does not have to be the same as the name of the document itself. In fact, you can use the shortest possible version of the name.

As the document here is second version of the previous one, so its name should be ProjectReport_v2.docx.

Thus, the correct option is D.

For more details regarding document, visit:

https://brainly.com/question/27396650

#SPJ2

For this lab you will write a Java program that will run a simple math quiz. Your program will generate two random integers between 1 and 20 and then ask a series of math questions. Each question will be evaluated as to whether it is the right or wrong answer. In the end a final score should be reported for the user.

This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program.

Enter your name: Jeremy
Welcome Jeremy! Please answer the following questions:

4 + 6 = 10
Correct!

4 * 6 = 24
Correct!

4 / 6 = 1
Wrong!
The correct answer is 0

4 % 6 = 4
Correct!

You got 3 correct answers
That's 75.0%!

Your code will behave differently based on the random numbers it selects and the answers provided by the user. Here is a second possible execution of this code:

Enter your name: Bob
Welcome Bob! Please answer the following questions:

3 + 3 = 0
Wrong!
The correct answer is 6

3 * 3 = 6
Wrong!
The correct answer is 9

3 / 3 = 0
Wrong!
The correct answer is 1

3 % 3 = 1
Wrong!
The correct answer is 0

You got 0 correct answers
That's 0.0%!

Answers

Answer:

A java program was used to run a simple math quiz. the program was used to generate two random integers between 1 and 20 and then ask a series of math questions

Explanation:

Solution

THE CODE:

import java.util.Random;

import java.util.Scanner;

public class LabQuiz {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.println("****Welcome to Quiz******");

System.out.print("Enter your name: ");

String name = in.next();

System.out.println("Welcome "+name+"! Please answer the following questions:");

int scoreCounter=0;

int a;

int b;

int response;

a=getRandomNum();

b=getRandomNum();

System.out.print(a+"+"+b+"=");

response = in.nextInt();

if(response==(a+b)){

scoreCounter++;

System.out.println("That is correct");  

}  

else

System.out.println("No, thats not the right answer, its::"+(a+b));

a=getRandomNum();

b=getRandomNum();

System.out.print(a+"*"+b+"=");

response = in.nextInt();

if(response==(a*b)){

scoreCounter++;

System.out.println("That is correct");  

}  

else  

System.out.println("No, thats not the right answer, its::"+(a*b));

a=getRandomNum();

b=getRandomNum();

System.out.print(a+"/"+b+"=");

response = in.nextInt();

if(response==(a/b)){

scoreCounter++;

System.out.println("That is correct");

}

else

System.out.println("No, thats not the right answer, its::"+(a/b));

a=getRandomNum();

b=getRandomNum();

System.out.print(a+"%"+b+"=");

response = in.nextInt();

if(response==(a%b)){

scoreCounter++;

System.out.println("That is correct");  

}

else

System.out.println("No, thats not the right answer, its::"+(a*b));

System.out.println("You got "+scoreCounter+" correct answers.");

System.out.println("Thats "+(scoreCounter*25)+"%");

in.close();  

}

static int getRandomNum(){

Random rand = new Random();

int a;  

a = rand.nextInt(20);

if(a==0)

a++;  

return a;  

}  

}

Other Questions
Traffic speed: The mean speed for a sample of cars at a certain intersection was kilometers per hour with a standard deviation of kilometers per hour, and the mean speed for a sample of motorcycles was kilometers per hour with a standard deviation of kilometers per hour. Construct a confidence interval for the difference between the mean speeds of motorcycles and cars at this intersection. Let denote the mean speed of motorcycles and round the answers to at least two decimal places. A confidence interval for the difference between the mean speeds, in kilometers per hour, of motorcycles and cars at this intersection is ________.Construct the 98% confidence interval for the difference 1-y 2 when x 1 475.12, x 2-32134, s 1-43.48, s 2-21.60, n 1-12, and n 2-15. Use tables to find the critical value and round the answers to two decimal places. A 98% confidence interval for the difference in the population means is ________. Determine theequation of a linethat has anx-intercept of 3 anda y-intercept of 4. What effect do body fossils have on how people understand dinosaurs?A)They show the types of food dinosaurs ate.B)They give evidence of how prehistoric life behaved.C)They let people know what dinosauts looked like.D)The reveal how the dinosaurs raised their young. How many moles of iron(III) sulfide,Fe2S3, would be produced from thecomplete reaction of 449 g iron(III)bromide, FeBr3? A study shows that 35% of the fish caught in a local lake had high levels of mercury. Suppose that 10 fish were caught from this lake. Find, to the nearest tenth of a percent, the probability that at least 6 of the 10 fish caught did not contain high levels of mercury. What supplies energy for the water cycle? How did imperialism during the late 19th century differ in Africa and in LatinAmerica?O A. Africa prospered greatly from imperialism, but Latin Americaexperienced an economic depression.B. Africa was dominated through economic imperialism, but LatinAmerica was colonized militarily.C. Africa resisted imperialism through violent uprisings, but LatinAmerica welcomed European imperialism.O D. Africa was divided between European powers, but Latin Americawas dominated by the United States. Which of the following gives computers the ability to understand unpredictable language, based on the way humans speak and write? Machine learning Deep learning Natural language processing Computer vision Narrow AI Which inequality pairs with y2x1 to complete the system of linear inequalities represented by the graph? y2x+2 y2x2 Which three events caused serious damage to Confederate morale and ultimately led to the Confederacys defeat?Shermans March to the SeaMcClellans presidential campaignLincolns reelection as presidentthe assassination of President Lincolndefeat in the battle of Gettysburg A long metallic wire is stretched along the x direction. The applied potential difference alongthe wire is 12 volts. The resistance of the wire is estimated to be 8 Ohm.a. Calculate the current in the wire and the passing charge in 2 seconds.b. Calculate the electric power dissipated in the wire.This wire has a length of 100 m and the material of the wire has a resistivity of 1.6 x 10 -8 m.c. Calculate the cross-section area of the wire.d. Calculate the conductivity of the wire.e. What is the capacitance of the capacitor, that is connected to a series resistor of 8 M in an RCcircuit that has a time constant of one second. Solve the equation, keeping the value for x as an improper fraction. 2/3 x = 1/2 x + 5 The thyroid, parathyroid, and thymus are located in theThe adrenals, pancreas, testes, and ovaries are located in theThe pineal, hypothalamus, and pituitary are located in the A chemist performed a calibration method analysis to determine the concentration of vitamin c in a fruit sample. The standard vitamin c samples were prepared by mixing a complexing agent with the standard solution. The absorbance of the resulting solution was obtained. Once the absorbance of each standard solution was measured, he prepared the following calibration curve.y = 1.6421x -0.1113The unknown sample was prepared by taking 2.0 g of crushed fruit and extracting the concentrated juice. The extracted juice was added to 100.0 mL volumetric flask and the final volume was adjusted 100.0 mL with DI water. 10.0 mL of diluted fruit extra was pipetted into 50.0 mL volumetric flask and after adding 5.0 mL of complexing agent, the DI water was added until the final volume of the solution reaches 50.0 mL. This solution gave an absorbance of 0.461. I. Find the concentration of vitamin C in the original fruit sample. II. What is the total mass of vitamin C in the sample? III. Calculate the wt% of vitamin C in the fruit sample. Forever Jewelers uses the perpetual inventory system. On April 2, Forever sold merchandise with a cost of $ 1 comma 500$1,500 for $ 9 comma 000$9,000 to a customer on account with terms of 22/15, n/30. Which of the following journal entries correctly records the sales revenue? a. Accounts Receivable 6,720 Sales Revenue 6,720 b. Sales Revenue 6,720 Accounts Receivable 6,720 c. Sales Revenue 6,720 Cost of Goods Sold 6,720 d. Accounts Receivable 1,500 Sales Revenue 1,500 If the surface soil is saturated and precipitation increases, there will bea. a decrease in the surface elevation of the lake b. a decrease in the amount of groundwater c. an increase in the rate of capillarity d. an increase in the amount of runoff In this activity, you will write a persuasive article that is approximately one to two pages in length. Select a topic of interest to you, such as a current event, a popular trend, or a school or government policy. Whatever topic you select, try brainstorming about it to develop your point of view. Writing multiple drafts can help you strengthen your opinion. Remember that in a persuasive text, your goal is to sway the reader to agree with your opinion. Use persuasive techniques, such as scientific data or emotional appeals, to persuade your audience. As you conduct outside research, be sure to cite these resources properly in a bibliography. I need help with this What does the point marked on the green line represent? Please help me find the volume and explain how you found it in a clear form