Sorting and Searching
Hi i would really be thankful if someone could help me with this
A program is required to ask users to rate the Java programming language using a number in the range 0 - 10.
The data input is ended by entering -1.
After all the votes have been counted, the program should output a table showing how many people gave each rating and the average rating.
import java.util.*;
class RateJava {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Rate Java(0-10): ");
int rate = input.nextInt();
while (rate > 10 || rate < 0) {
catch(
private static class IOException {
public IOException() {
}
}
ArithmeticException e
);
{
System.out.println("Cannot calculate average - no data");
catch(IOException
);
{
System.out.println("Error reading from file");
}
}
}
}
System.out.print("Invalid! Rate Java within the range(0-10): ");
rate=input.nextInt();
System.out.println("You have rated Java: "+rate);
View Answers
December 9, 2011 at 4:56 PM
import java.util.*;
class RateJava
{
public static void main(String[] args)
{
int c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0,c8=0,c9=0,c10=0,c11=0;
Scanner input=new Scanner(System.in);
int rate=0;
do{
System.out.print("Rate Java(0-10): ");
rate=input.nextInt();
if(rate>10||rate<-1){
System.out.print("Invalid! Rate Java within(0-10): ");
rate=input.nextInt();
}
if(rate==0){
c1++;
}
if(rate==1){
c2++;
}
if(rate==2){
c3++;
}
if(rate==3){
c4++;
}
if(rate==4){
c5++;
}
if(rate==5){
c6++;
}
if(rate==6){
c7++;
}
if(rate==7){
c8++;
}
if(rate==8){
c9++;
}
if(rate==9){
c10++;
}
if(rate==10){
c11++;
}
if(rate==11){
c1++;
}
}
while(rate!=-1);
System.out.println();
System.out.println("*****RATINGS*****");
System.out.println("Number of users rated Java 0: "+c1);
System.out.println("Number of users rated Java 1: "+c2);
System.out.println("Number of users rated Java 2: "+c3);
System.out.println("Number of users rated Java 3: "+c4);
System.out.println("Number of users rated Java 4: "+c5);
System.out.println("Number of users rated Java 5: "+c6);
System.out.println("Number of users rated Java 6: "+c7);
System.out.println("Number of users rated Java 7: "+c8);
System.out.println("Number of users rated Java 8: "+c9);
System.out.println("Number of users rated Java 9: "+c10);
System.out.println("Number of users rated Java 10: "+c11);
}
}
Related Tutorials/Questions & Answers:
Sorting and SearchingSorting and Searching Hi i would really be thankful if someone could help me with this
A program is required to ask users to rate the Java programming language using a number in the range 0 - 10.
The data input is ended
Java Sorting and Searching Java
Sorting and
Searching If anyone could help me with this I would be really thankful!
Write a program that stores the names of these artists in a String array. The program should prompt the user to enter the name
Advertisements
Insertion, sorting and searching in array;
}
Insertion,
sorting and
searching in array
... to perform
searching
and
sorting in array. In the java code given below we have...("\nArray elements after
sorting", array);
// Search for element
sorting sorting write a program to arrange
sorting in rows,column and diagonal
SortingSorting can any help me know which
sorting algorithm java uses for
sorting collection and arrays
sortingsorting write to a program to arrange the
sorting in rows, column and digonal
sortingsorting how to do
sorting without using bubble sort,selection sort
searching bookssearching books how to write a code for
searching books in a library through jsp
searching techniquesearching technique Hi,
i need any
searching technique in java to search the data and give the all possible data by links
searching problemsearching problem how we can make a code in core java for
searching in hard disk?
i have to make an antivirus as my minor project , so i have need this type code to search the virus in hard disk
searching problemsearching problem how we can make a code in core java for
searching in hard disk?
i have to make an antivirus as my minor project , so i have need this type code to search the virus in hard disk
file searchingfile searching i need a prog for
searching inside a text file after evry 1 min to find does it hav any new entry
searching stringsearching string how to write a program for
searching a string
Hi Friend,
Try this:
import java.util.*;
class SearchString{
public static void main(String[] args){
Scanner input=new Scanner(System.in
searching the datasearching the data respected sir ,
i am making the desktop application ,
so how can i search the data which are stored in the mysql databses through click the button and display in jtable through netbeans dynamically
linear sortinglinear sorting what is linear
sorting?
can any send me an example
Hi Friend,
Try this:
import java.util.*;
class ArraySort{
public...("After
Sorting: ");
for(int i=0;i<arr.length;i++){
System.out.println
Sorting ProgramSorting Program To sort 10items in alphabetical order
Arrays.sort(name of ur array)
import java.util.*;
class ArrayExample{
public static void main(String[] args) {
String array[]=new
sorting numberssorting numbers How to sort the numbers in ascending order
import java.util.*;
class SortNumbers{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in
Java sorting sorting mechanism.
say about Collections.Sort() & Arrays.Sort() that uses
Sorting an ArrayListSorting an ArrayList print("code sample");Hello All,
I am working on a program for school and I am having trouble with
sorting my list. The numbers I receive in my output are correct, but not in ascending order as required
Bubble Sorting in JavaBubble
Sorting in Java Hi,
What is Bubble
Sorting? Guide me where to learn Bubble
Sorting in Java?
Thanks
Hi,
Check the tutorial at Bubble
Sorting in Java.
Thanks
Sorting the arraySorting the array Implement a program to process votes for 5 candidates in a talent contest.
The program should use a String array to hold the names of the 5 candidates and an integer array to record the number of votes for each
searching inside a file for detailssearching inside a file for details i created a file with name,country,state etc...when i'm
searching for the name, i have to get other details like country,state etc...please do help
searching the string in a paragraph?searching the string in a paragraph? how to search a string in a paragraph and display the corresponding line number and position of a string in java
ModuleNotFoundError: No module named 'sorting'ModuleNotFoundError: No module named '
sorting' Hi,
My Python... '
sorting'
How to remove the ModuleNotFoundError: No module named '
sorting... to install padas library.
You can install
sorting python with following command
Searching for Code - JSP-ServletJSP, Servlet
Searching for Code Hi, i am looking for a jsp servlet code examples for the search function in my application.Thanks
searching from databasesearching from database how to search data from data base throug search...such as contact no./lastname /firstname should give whole information from database...
Please visit the following link:
Servlet search
Searching an element - JSP-ServletSearching an element Dear sir,
sir i have an employee... in that i am doing a
searching an element by empId and displaying a all... field for
searching an element by the empId.and one submit button for submitting
Searching an element - JSP-ServletSearching an element Dear sir,
sir i have an employee table... doing a
searching an element by empId and displaying a all the employee table... for
searching an element by the empId.and one submit button for submitting this form.And
Java String searching.Java String
searching. How to search a string in given String array?
import java.util.Scanner;
public class StringSearch {
public... and for
searching
we used userCity.equalsIgnoreCase(city[i
Searching English words in a stringSearching English words in a string My task is to find English words and separate them from a string with concatenated words..for example
AhdgdjHOWAREgshshYOUshdhfh
I need to find if there exists any English words.
Searching operation in JAvaSearching operation in JAva Sir,
I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAvaSearching operation in JAva Sir,
I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAvaSearching operation in JAva Sir,
I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAvaSearching operation in JAva Sir,
I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
searching for strings in a filesearching for strings in a file how can i search of a person and display the other details associated with the name using java gui window?
import java.util.ArrayList;
import javax.swing.*;
import java.awt.event.
sorting Line in csorting Line in c Hi I need help with
sorting line in programming c
asking user to enter 1-10 characters and then sort them in lower case, alphabetical and ascending order. Any help will be appreciated! please help!
void
Imp-HTML Table Sorting Imp-HTML Table
Sorting Hi,
I am working on a project and as per requirement from client i have to sort a table based on the ID Column.
I want... of HTML table
sorting where
sorting happenes whenever user clicks on column header
Sorting along life spanSorting along life span how to find total age in date of birth and date of death.and also sort along life span.using object class and collection API
Array Sorting - Development processArray Sorting Hello sir,
Now i m doing various Array
sorting(Bubble,insertion,Quick,merge etc )
I want to display Array Sort in steps by step like... is the code to display array
sorting with moving graphics(color)in steps
sorting array in javasorting array in java How to sort array in Java or JavaScript?
JavaScript
Sorting array tutorial
Java Sort array of strings
import java.util.*;
class ArrayExample{
public static void main(String
Finding searching phrase of a search engineFinding
searching phrase of a search engine how to find out
searching phrase of a search engine..? like, if visitors enter the keyword to google, is is any possible to get that keyword
Sorting algorithms - Java BeginnersSorting algorithms I'v being given an assignment and I still couldn't find a proper answer for the following questions.Can anyone pls pls help me wi it?
1)Compare and contrast efficiencies of Shell,Quick,Heap and Radix sort
Sorting the letters in a StringSorting the letters in a String I have recently learned how to sort different strings using the insertion sort method but I still cannot sort the letters in one particular string. For instance, if I enter in the string "Hello my