Print the name and number

Assignment Help JAVA Programming
Reference no: EM13759463

Question is to print the name and number you entered in order either asked by name or number.

package roaster1;
importjava.util.*;
publicclass roaster1 {
@SuppressWarnings("resource")
publicstaticvoid main(String[] args){
String [] last = newString[5];
int [] grade = newint[5];
intcount=0;
intselection = 0;
charin='Y';

inta,b;

Scanner keyboard = newScanner(System.in);
System.out.println("Please enter your grade>>");
grade[count]= keyboard.nextInt();
while( count< 5 &&in !='N'){
System.out.println("Please enter your Last Name>>");
last[count]= keyboard.next();

     count= last.length;
System.out.println("Please enter grade from 1-100>>");
a= keyboard.nextInt();
if ( a>=0 &&a<=100){
grade[count]=a;
}

else {
System.out.println("Please enter grade Again from 1-100>>");
b=keyboard.nextInt();
grade[count]=b;
++count;
}
System.out.println("Continue? Enter Y for Yes and N for NO?");
in= keyboard.next().toUpperCase().charAt(0);
}//While end
do {
System.out.println("");
System.out.println("Please choose an option");
System.out.println("1. Arrange By Student Name");
System.out.println("2. Arrange By Student Grade");
System.out.println("3. Exit Program");
System.out.println("");
selection = keyboard.nextInt();

switch(selection){
case 1:
case 2:
Bubble(last,grade,selection,count);
//Print(last, grade,count);
}//end switch
}while (selection !=3);//end do
}//main ends

privatestaticvoid Bubble(String[] name, int[] grade, intCheck,
intcount) {
String nme=null;
intgrd = 0;

if ( Check==1){
for ( intj=1; j<count; j++){
for( inti=1; i<= count-1; i++){
if (name[i-1].compareTo(name[i])>0){
nme = name[i-1];
grd = grade[i-1];
name[i-1]=name[i];
grade[i-1]=grade[i];
name[i]=nme;
grade[i]=grd;
}// if end
}//end for inner loop.b

}//end for outer loop.
System.out.println("Name\tGrade");
for (inti=0; i<count; i++){
System.out.println(name[ i]+""+grade[i]);
}
}//if for check end

else{
for (intj=1; j<count; j++){
for(inti=1; i<= count-1; i++){
if (grade[i-1] <grade[i]){
nme = name[i-1];
grd = grade[i-1];
name[i-1]= name[i];
grade[i-1]= grade[i];
name[i]= nme;
grade[i]=grd;
}//end for else for outer loop.
}//end for else for inner loop
}//end for else if last part for swap.
System.out.println("Name\tGrade");
for (inti=0; i<count; i++){
System.out.println(name[ i]+""+grade[i]);
}
}//else end
}//bubble class end
}//roaster class end.

Reference no: EM13759463

Questions Cloud

Outline for a standards manual for your data warehouse : Prepare an outline for a standards manual for your data warehouse. Consider all types of objects and their naming conventions. Indicate why standards are important. Produce a detailed table of contents.
White-hat hackers to breach systems : Go online and search for information about Operation Eligible Receiver. What details can you find? For example, which government systems were infiltrated? How difficult was it for white-hat hackers to breach those systems?
Describe the merits of OLAP : As a senior analyst on the project team of a publishing company exploring the options for a data warehouse, make a case for OLAP.  Describe the merits of OLAP and how it will be essential in your environment.
Data warehouse with those in operational systems : Compare the usage and value of information in the data warehouse with those in operational systems. Explain the major differences. Discuss and give examples.
Print the name and number : Question is to print the name and number you entered in order either asked by name or number.
For health-related companies such as weight watchers : For health-related companies such as Weight Watchers, one of the most frequent ethical issues related to communications that they face is
About the insurance busines : Assume you are in the insurance business.  Find two examples of type 2 slowly changing dimensions in that business.  As an analyst on the project, write the specifications for applying the type 2 changes to the data warehouse with regard to the two e..
Effectiveness of the physical and environmental security : Evaluate the effectiveness of the physical and environmental security measures that the organization you researched used in regard to protecting its assets
Explain how eliade uses the concepts of chaos and cosmos : Explain how Eliade uses the concepts of "chaos" and "cosmos" to describe the origins of the universe as essentially a mythic or religious account of the work of the gods.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Program (using java) that is suppose to find the largest

writing a program (using java) that is suppose to find the lowest integer that can be evenly divided by a range (ex. 1-25). I need help fixing/debugging it so it comes up with the proper output.

  Display the value stored at the index

Display the value stored at the index. Take a screenshot to verify that the words in your Array or ArrayList are displayed successfully.

  Allows a user to select a favorite basketball team

Write an application that allows a user to select a favorite basketball team from a list box. Include at least five teams in the list, and display the chosen team in a text field after the user makes a selection. Save the file as JBasketball.java. :

  Solve the currently very un-pc cigarette smokers problem

Write solution to solve the currently very un-PC"cigarette smokers problem" in java using Java threads, and monitors (using the "synchronized" keyword) (If it bothers your PC sensibilities, think of it at the Pot-smokers problem and then it is all pr..

  Allows the user to enter students names followed

Write a program that allows the user to enter students names followed by their test scores and outputs the following information(assume that the maximum nmber of students in the class is 50

  A program called invoice that will prompt the user for items

write a program called invoice that will prompt the user for items on and invoice and then print the total of the invoice

  Discuss key environmental issues facing north america

Discuss the key environmental issues facing North America based on the discussion in the text. Which ones do you see threatening the quality of life in North America the most? Do you have any ideas on how these issues might be addressed?

  These are more specialized versions of the pizzaorders you

your pizza shop expands and now handles delivery orders and sit down orders in a restaurant setting. there are

  Java application that asks a user to enter two integers

Write a Java application that asks a user to enter two integers (A and B) and then display the results of A/B. Catch any division by zero errors and prompt the user to reenter the value of B. Be sure your code compiles and runs as expected. Name your..

  Write a java program to compute salary

Write a Java program which computes the Salary for a given number of employees. The program prompts user to enter n the number of employees.

  Identify the 5 code elements

Identify the 5 code elements for a Password class. Things like: class, instance, and final variables, accessor and mutator method, public and private specifiers for methods and member variables.i need to provide detail and descriptions for each code ..

  Write java program prints strings given at command line

Write down the program Average.java which just prints strings which it is given at command line, one per line. If nothing is given at command line, print "No arguments".

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd