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
zavuch27 [327]
2 years ago
6

Given the String variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (a

ssume that all three are already declared and that name1 and name2 have been assigned values). (Note: "larger" here means alphabetically larger, not "longer". Thus, "mouse" is larger than "elephant" because "mouse" comes later in the dictionary than "elephant"!)
Computers and Technology
1 answer:
Neporo4naja [7]2 years ago
6 0

Answer:

if ( name1 > name2) {

    first = name1;

} else {

    first = name2;

}

Explanation:

First you need take a decision for that reason you need and if - else structure to decide if asign the variable name1 or the variable name2 to the result. Later you can use an > or < to compare two strings because it use the ASCII code to compare wich one is larger than another.

if ( name1 > name2) {

    first = name1;

} else {

    first = name2;

}

You might be interested in
Write a method that determines the total number of chars in each string of an array.
Serjik [45]
The total number of chars in each string is basically the size of each string.

Using JAVA:

        String[] arr = {"hello", "my", "name", "is", "Felicia"};                int count = 0;        for(int i = 0; i < arr.length; i++) {            count = count + arr[i].length();            System.out.println("Characters in " + arr[i] + ": " + count);        }

Output: 
<span>Characters in hello: 5
Characters in my: 7
Characters in name: 11
Characters in is: 13
Characters in Felicia: 20</span>


8 0
3 years ago
Keyboards and printers are two examples of _________ devices.
galben [10]
Input device your welcome
8 0
3 years ago
1. Extract title Write a function extract_title that takes one parameter, the filename of a GenBank formatted file, and returns
trapecia [35]

Answer:

def extract_title(file):

   import re

   a =''

   with open(file,'r') as file:

       for line in file:

           a += line

       m = re.search("^(TITLE)(.*?)(JOURNAL)", a, re.M + re.S)

       print(m.groups()[1])

extract_title('new.txt')

Explanation:

The programming language used is python 3.

The function is first defined and the regular expression module is imported.

A variable is initialized to an empty string that will hold the content of the GenBank formatted file.

The file is opened and every line in the file is assigned to the string variable. The WITH statement allows files to be closed automatically.

Regular expression is used to capture all the files between TITLE and JOURNAL in a group.

The group is printed and the function is called.

I have attached a picture of the code in action.

6 0
3 years ago
Write a Python function that join the two string and print it ​
liubo4ka [24]

Answer:

string1 = "this is string 1"

string2 = " this is string 2"

print(string1 + string2)

Explanation:

the string1 variable is assigned with a string value(aka. str)

string2 is also a variable assigned with a slightly different string value

the 3rd line then prints string 1 and 2 to the console.

5 0
2 years ago
Read 2 more answers
Write a program for Horizon Phones, a provider of cellular phone service. Prompt a user for maximum monthly values for talk minu
Anarel [89]

Answer:

mport java.util.Scanner;

public class CellPhoneService

{

    public static void main (String args[])

    {

         Scanner sc=new Scanner(System.in);

         System.out.println("Enter the Talk minutes");

         int talkmin=sc.nextInt();

         System.out.println("Enter the text message");

         int textmsg=sc.nextInt();

         System.out.println("Enter the Gigabyte Data");

         int gbdata=sc.nextInt();

         if(talkmin<500 && textmsg==0 && gbdata==0)

         System.out.println("PLAN A IS RECOMMENDED FOR THIS USER at 49$ per month");

         else if(talkmin<500 && textmsg>0 && gbdata==0)

         {

              System.out.println("PLAN B IS RECOMMENDED FOR THIS USER at 55$ permonth");

         }

         else if(talkmin>=500 && textmsg<100 && gbdata==0)

         {

              System.out.println("PLAN C IS RECOMMENDED FOR THIS USER at 61$ permonth");

         }

         else if(talkmin>=500 && textmsg>=100 && gbdata==0)

         {

              System.out.println("PLAN D IS RECOMMENDED FOR THIS USER at 70$ permonth");

         }

         else if(gbdata>0 && gbdata<2)

         {

              System.out.println("PLAN E IS RECOMMENDED FOR THIS USER at 79$ permonth");

         }

         else if(gbdata>=2)

         {

              System.out.println("PLAN F IS RECOMMENDED FOR THIS USER at 87$ permonth");

         }

    }

}

Explanation:

  • Take the talk minute and text message as input from user.  
  • Apply the conditional statement to check if talk minute is less than 500 along with text message and GB data having a value 0.
  • At last check if GB data is greater than or equal to 2, then print the relevant response.
3 0
3 years ago
Other questions:
  • Classify the given items as belonging to the public domain or protected by copyright law.
    6·2 answers
  • Which part of the os provides users and applications with an interface to manipulate files?
    8·1 answer
  • Many companies use software to scan resumes and search for _____________.
    10·1 answer
  • what type of clause must you always use with DEKETE or UPDATE to avoid inadvertently changing data elsewhere in the database​
    12·1 answer
  • #include &lt;iostream&gt;
    9·1 answer
  • Problem 3. Consider the following recurrence, defined for n a power of 4 (for the time of some algorithm): T(n) = 3 if n = 1 2T(
    5·1 answer
  • Which of the following best describes
    13·1 answer
  • Which of the following is a programming language that permits Web site designers to run applications on the user's computer?
    15·1 answer
  • Use the dropdown menus to complete the sentences about Live Preview and the Mini Toolbar Live Preview is a convenient way to see
    15·2 answers
  • When assigning a value to a string, which of the following rules needs to be followed?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!