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
Alik [6]
3 years ago
9

The array s of ints contain integers each of which is between 1 and 1000 (inclusive). write code that stores in the variable ord

inals the array of strings consisting of each number followed by its ordinal number abbreviation, "st", "nd", "rd", or "th". for example if s is the array
Computers and Technology
1 answer:
bearhunter [10]3 years ago
7 0

Answer and  Explanation

An array holds a fixed number of values of a single type. Its length is established when the array is created where the length is fixed after the creation.In c programming an array is a collection of data items all of them of the same type and accessed using a common name while in Java  they are items that are dynamically created and all elements have the same type called the component type  of the array.

//takes an array of int and returns an array of String the way you want!  

public String[] setOrdinal(int[] arr)  

{  

String[] ord = new String[arr.length];  

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

{  

ord[i] = convert(arr[i]);  

}  

return ord;  

}  


//takes a number and converts it to string and adds the proper letters


private String convert(int num)  

{  

if(num > 1000 || num <=0)  

return "Not in range";  

else if(num%10==0 || num%10==9 || num%10==8 || num%10==7 || num%10==6 || num%10==5 || num%10==4 || num%10==3)  

{  

return String.valueOf(num) + "th";  

}  

else if(num%10==2)  

{  

if((num/10)%10==1) //checks if the second digit is 1  

return String.valueOf(num) + "th";  

else  

return String.valueOf(num) + "nd";  

}  

else  

{  

if((num/10)%10==1)  

return String.valueOf(num) + "th";  

else  

return String.valueOf(num) + "st";  

}

}

You might be interested in
Which of these components is a part of the central processing unit (CPU) of a computer? A. memory B. storage C. control unit D.
erma4kov [3.2K]
The answer is C. control unit
8 0
3 years ago
Read 2 more answers
Using positive self talk is a great way to
lora16 [44]
Boost your self esteem and confidence.
7 0
3 years ago
Read 2 more answers
Describe the effect of a pull up resistor
Vesna [10]
With a pull-up resistor, the input pin will read a high state when the button is not pressed. In other words, a small amount of current is flowing between VCC and the input pin (not to ground), thus the input pin reads close to VCC. When the button is pressed, it connects the input pin directly to ground.
3 0
4 years ago
After reading passage “the incredible machine” why do you think the article has been titled so?
Vitek1552 [10]
I haven’t read it, but just by the title it was probably talking about an incredible machine that was new to people.
7 0
3 years ago
When working in the navigation pane, you ____ a folder to open it?
SpyIntel [72]
When working in the navigation pane, you click a folder to open it
3 0
3 years ago
Other questions:
  • The main storage device inside a computer where programs and files are saved is called the
    5·1 answer
  • Answer the following questions which are based on the study "Patients' Engagement with Sweet Talk." Submit your answers to the e
    9·1 answer
  • The operation:
    8·1 answer
  • The ____ of a variable is the location in memory where it’s value is stored. A. Value B. Address C. Data type D. Number
    8·1 answer
  • You want to save twenty of your vacation pictures on your computer. Which is the best place to save them?
    6·2 answers
  • 3. It is used to measure the resistance on ohms and voltage that flow in circuit both AC and DC current. A. Gadget C. Electrical
    12·1 answer
  • Where can i make an animation for free?
    10·1 answer
  • Create a presentation on “Pets” and customize your presentation in the following ways:
    10·1 answer
  • After turning volume all the way up on your computer speaker you still can’t hear any sound. What should be done next
    15·1 answer
  • What statement is accurate in regards to
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!