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
Lady_Fox [76]
4 years ago
10

Write a method min that has three string parameters and returns the smallest.

Computers and Technology
1 answer:
Nata [24]4 years ago
8 0
Public String min (String aString, String bString, String cString)
{
if(aString.compareTo(bString)<0 && aString.compareTo(cString)<0)
{
return aString
}
else if (bString.compareTo(cSgtring)<0 && bString.compareTo(aString)<0
{
return bString;
}
else 
{
return cString;
}
}
You might be interested in
Write a C++ program that overloads a function named LinearSearch that searches an array of data of either integer data type, flo
frutty [35]

Explanation:

#include <iostream>

#include <vector>

#include <iomanip>

using namespace std;

/*

Overloading means equal function name with different call prototype each.

It's a useful tool that lets you think once and write similar role code twice or more times keeping equal function name.

Please look at lines 12-14: they are overloaded call prototype versions of LinearSearch with identical mission (to know if a value is present in a set)

*/

//#define GENERICS

#ifndef GENERICS                                                                // Conditional compilation statement

bool LinearSearch(vector<int>   ,int);

bool LinearSearch(vector<float> ,float);

bool LinearSearch(vector<double>,double);

#else                                                                           // Conditional compilation statement (uncomment line 10 statement)

template <typename genType>

bool LinearSearch(vector<genType> v, genType value);                            // LinearSearch (generic type parameters version)

#endif

int main(int argc, char *argv[]) {                                              // Test code follows:    

vector<int> vInt    {1,                     -2,     3,          -4,     5};     // Test data (int)

vector<float> vFlo  {1.23456f,              -2.35f, 3.1416f,    -4.7f,  5.55f}; // Test data (float)

vector<double> vDou {1.234567890123456789,  -2.35,  3.1415927,  -4.7,   5.55};  // Test data (double)

cout <<3 << "        is " << (LinearSearch(vInt,3)      ?"":"not ") << "in: {";for(auto x:vInt) cout << setw(11) << x;cout << "}\n";

cout <<3.1416f<< "   is " << (LinearSearch(vFlo,3.1416f)?"":"not ") << "in: {";for(auto x:vFlo) cout << setw(11) << x;cout << "}\n";

cout <<3.14   << " is " << (LinearSearch(vDou,3.1416) ?"":"not ") << "in: {";for(auto x:vDou) cout << /*setprecision(9)<<*/setw(11) << x;cout << "}\n";

return 0;

}

#ifndef GENERICS

// Overloaded function code follows:

bool LinearSearch(vector<int> v, int value) {                                   // LinearSearch (integer parameters version)

bool found = false;                                                             // Until now we haven't found the value we are searching for,

for(auto x:v) found = found || x == value;                                      // but if it is here found becomes true.

return(found);

}

bool LinearSearch(vector<float> v, float value) {                               // LinearSearch (float parameters version)

bool found = false;

for(auto x:v) found = found || x == value;

return(found);

}

bool LinearSearch(vector<double> v, double value) {                             // LinearSearch (double float parameters version)

bool found = false;

for(auto x:v) found = found || x == value;

return(found);

}

/*

So far, so good. It works! But, despite there was little effort involved, redundant code remains.

Is there any solution? Yes! It's called generic programming.

*/

#else

/*

Consider the following code:

   - Template statement at first accepts a generic type as a parameter (genType)

   - genType is used for both parameters (array and value to search)

   - Template statements located after generic version of LinearSearch instructs compiler to generate each type version

Conclusions:    

   - Compared with overloaded versions generic code is more elegant and avoids completely redundancy

   - It enhances overloading while keeping its advantages

*/

template <typename genType>

bool LinearSearch(vector<genType> v, genType value) {   // LinearSearch (generic type parameters version)

bool found = false;                                     // Until now we haven't found the value we are searching for,

for(auto x:v) found = found || x == value;              // but if it is here found becomes true.

return(found);

}

template bool LinearSearch(vector<int>   ,int);

template bool LinearSearch(vector<float> ,float);

template bool LinearSearch(vector<double>,double);

#endif

Download cpp
3 0
3 years ago
The process of sending a result back to another part of the program is
Oksi-84 [34.3K]

Answer:

The process of sending a result back to another part of the program is known as pushing a value False In Python, functions and other resources are coded in components called modules

Explanation:

4 0
3 years ago
Formatting can be applied to
valkas [14]
Formatting can maybe be applied to software works
8 0
3 years ago
Read 2 more answers
Write a program that prompts the user to input the number of quarters, dimes, and nickels. The program then outputs the total va
Anni [7]

Answer:

The program to this question can be given as follows:

Program:

#defining variable quarters, dimes, and nickels.

quarters=int(input("Enter value of quarters: ")) #input value by user  dimes=int(input("Enter value of dimes: ")) #input value by user  nickels=int(input("Enter value of nickels: ")) #input value by user  

#defining variable pennies

pennies = ((25*quarters)+(10*dimes)+(5*nickels)) #calculate value in pennies variable

print('Total number of coins in pennies is: ',pennies)#print value

Output:

Enter value of quarters: 3

Enter value of dimes: 2

Enter value of nickels: 1

Total number of coins in pennies is:  100

Explanation:

In the above python program code, firstly three variable "quarters, dimes, and nickels", all of these variable uses input function, that is used to take input value from the user side, in these variable, an int is used that defined, that user input only integer value.

  • After taking input from the user a new variable "pennies" is defined, which is uses the user input values and calculates its addition.
  • In the next line, print function is used, which uses variable "pennies" to print its calculated value.
7 0
3 years ago
When entering data into a cell, which keyboard key is used to remove characters to the left of the insertion point?
deff fn [24]
The backspace key is used for that
3 0
3 years ago
Other questions:
  • The distance at which wi-fi signals can travel ranges typically between ____ and ____.
    15·1 answer
  • Once the term of copyright has expired,a work
    15·1 answer
  • What language below is used to view and manipulate data that is stored in a relational database?
    6·1 answer
  • What are the 3 dimensions referenced when we say 3D?
    10·1 answer
  • Write a program in Cto define a structure Patient that has the following members
    12·1 answer
  • Wendy had been searching the internet for a great deal on jewelry. While looking at one site, a pop-up was displayed that told h
    11·1 answer
  • Given the 32-bit binary number:
    13·1 answer
  • A computer is made up of hardware and software ​
    5·1 answer
  • What is collaboration
    14·1 answer
  • What is<br> a an<br> output device
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!