1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
-BARSIC- [3]
3 years ago
8

Solve the following questions.

Computers and Technology
1 answer:
NeX [460]3 years ago
4 0

Answer:

The codes for the problem are given below

Explanation:

//Name class

public class Name

{

  private String first,last,middle;

 

  public Name(String first,String middle,String last)

  {

      this.first=first;

      this.middle=middle;

      this.last=last;

  }

  public String getNormalOrder()

  {

      return first+" "+middle+". "+last;

  }

  public String getReverseOrder()

  {

      return last+", "+first+" "+middle+".";

  }

  public String toString()

  {

      return first+" "+middle+" "+last;

  }

  public void setFirstName(String first)

  {

      this.first=first;

  }

  public void setMiddleName(String middle)

  {

      this.middle=middle;

  }

  public void setLastName(String last)

  {

      this.last=last;

  }

}

//TestNameClass class

public class TestNameClass

{

  public static void main(String[] args)

  {

      Name myname=new Name("John","K","Watson");

      myname.setFirstName("John");

      myname.setMiddleName("Q");

      myname.setLastName("Public");

      System.out.println("My name: ");

      System.out.println(myname.getNormalOrder());

      System.out.println(myname.getReverseOrder());

     

      Name friend=new Name("Sherlock","P","Holmes");

      System.out.println("Friend's name: ");

      System.out.println(friend.getNormalOrder());

      System.out.println(friend.getReverseOrder());

  }

}

You might be interested in
Compute change
Illusion [34]

Answer:

Explanation:

The following code is written in Java and modified to do as requested. It asks the user to enter a number that is saved to the amountToChange and then uses the % operator to calculate the number of 5 dollar bills and the number of 1 dollar bills to give back. A test case has been provided and the output can be seen in the attached image below.

import java.util.Scanner;

class ComputingChange {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       int amountToChange;

       int numFives;

       int numOnes;

       amountToChange = scnr.nextInt();

       numFives = amountToChange / 5;

       /* Your solution goes here */

       numOnes = amountToChange % 5;

       System.out.print("numFives: ");

       System.out.println(numFives);

       System.out.print("numOnes: ");

       System.out.println(numOnes);

   }

}

5 0
3 years ago
A unique aspect of Java that allows code compiled on one machine to be executed on a machine of a different hardware platform is
notka56 [123]

Answer:

Java's bytecode

Explanation:

To execute its operations, java programming languages uses bytecodes.

These bytecodes are literally instructions of a java virtual machine (or JVM). They are generated in form of a class file as soon as the java program is ran and executed. In other words, the java compiler compiles the code and generates the bytecode.

As soon as the bytecode is generated, it can be transferred to a different machine and platform completely and one can run this bytecode on this different machine.

8 0
3 years ago
When computing effect size, the sample size is ________.
NNADVOKAT [17]
Sample size  is not taken into account

8 0
3 years ago
) Consider the ambiguous CFG problem: given a context free grammar, does there exist a string that can be generated by two diffe
vodomira [7]

Answer:

See explaination

Explanation:

The post correspondence problem is: Given a_1, \ldots, a_n and b_1, \ldots, b_n , is there a sequence of indices 11. ..., im such that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} .

To reduce from the PCP to the ambiguous CFG problem, do the following. Add some more symbols c_1, \ldots, c_n and define the following languages:

L_{A} = \{a_{i_1}\ldots a_{i_k}c_{i_k}\ldots c_{i_1} \mid k \geq 1\}

L_{B} = \{b_{i_1}\ldots b_{i_k}c_{i_k}\ldots c_{i_1} \mid k \geq 1\}

L_{AB} = L_A \cup L_B .

Define the following grammar for the language L_{AB} :

S \to S_{A} \mid S_{B}

S_A \to a_iS_Ac_i \mid a_ic_i, 1 \leq i \leq n

S_B \to b_iS_Bc_i \mid b_ic_i, 1 \leq i \leq n

It is easy to see that the given grammar generates the langauge L_{AB} . The reduction outputs the grammar thus constructed.

To see why this is a valid reduction, let there be a solution to the post correspondence problem, i.e. 11. ..., im such that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} . Then the string a_{i_1}\ldots a_{i_m}c_{i_m}\ldots c_{i_1} = b_{i_1}\ldots b_{i_m}c_{i_m}\ldots c_{i_1} has two difference derivations in the given grammar, one using S_A and the other using S_B .

Conversely, let a string generated by the given grammar have two different derivations. Note that S_A and S_B can only generate one derivation tree for any string, hence the only way for two different derivations to happen is for one of them to go to S_A and the other to S_B .

Let the string for which ambiguity appears be of the form a_{i_1}\ldots a_{i_m}c_{i_m}\ldots c_{i_1} . Then the other derivation must produce a string of the form b_{i_1}\ldots b_{i_m}c_{i_m}\ldots c_{i_1} , this is because both derivations must produce the same string for ambiguity to occur, hence the part which uses c_i must be the same. Note that this further implies that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} , which is equivalent to saying that the post correspondence problem has a solution.

Hence the reduction works as expected. This proves that the ambiguous CFG problem is undecidable, otherwise post correspondence problem would be decidable, which is a contradiction.

4 0
3 years ago
Question # 4
bezimeni [28]

Answer:

the last one I think not 100% sure

6 0
4 years ago
Other questions:
  • Array elements must be ________ before a binary search can be performed.
    8·1 answer
  • EASY POINTS
    5·1 answer
  • What do commercial websites use to estimate a visitor's age, gender, and zip code?
    10·1 answer
  • Which sentence(s) below are true?a. IP stands for Internet Protocol.b. In most home networks IP addresses are assigned by the In
    6·1 answer
  • In cell J6, insert a formula using the OR function that returns TRUE if the rating (cell 16) equals "A" or the email reminder (c
    5·1 answer
  • When performing forensics on an Apple computer, what operating system are you the most likely to encounter QUIZLET
    15·1 answer
  • The events that happen in a story are called the _________________.
    14·2 answers
  • You are the network administrator for a rapidly growing company with a 100BaseT network. Users have recently complained about sl
    7·1 answer
  • In Python, when do we use the str( ) function
    13·1 answer
  • A(n) Blank______ database model stores data in the form of logically related two-dimensional tables. Multiple choice question. w
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!