CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2014
    Posts
    2

    Need help with displaying programme output vertically. Programme details below!

    Could you help me out please,

    on the code below.



    Current Display OUTPUT:

    0-29 *****
    30-39 ****
    40-69 *****
    70-100 ***

    Highest:
    Lowest:
    Average:
    Total Students:

    I WANT IT LIKE THIS!!

    The histogram shows each category horizontally across the screen. Copy your original*
    solution and make changes to the copy to display the histogram vertically so the stars in a*
    category should go downwards and not across the screen, e.g.:
    0-29 30-39 40-69 70-100
    ** * * * * ** * * * * * * * * * * * * * * * * * * * * * * * * * *(as it prints the line decide if each category needs a star or space)*
    ** * * * * **
    **




    CODE STARTS HERE!

    /*
    ** To change this license header, choose License Headers in Project Properties.
    ** To change this template file, choose Tools | Templates
    ** and open the template in the editor.
    **/

    package historgrame.project;

    import java.util.Scanner;
    import javax.swing.JOptionPane;

    /**
    **
    ** @author w1497109
    **/
    public class HistorgrameProject {

    * * /**
    * * ** @param args the command line arguments
    * * **/
    * * public static void main(String[] args) {
    * * * * // TODO code application logic here

    * * * * int students = 0;
    * * * * int marks = 0;
    * * * * int highest = 0;
    * * * * int lowest = 100;
    * * * * double average = 0;
    * * * * int totalmarks = 0;
    * * * * int passed = 0;
    * * * **
    * * * * int counter1=0 ;
    * * * * int counter2=0;
    * * * * int counter3=0;
    * * * * int counter4=0;
    * * * **
    * * * * Scanner input=new Scanner(System .in);
    * * * * while (marks <=100){
    * * * * * * System.out.println("Enter Marks here : ");
    * * * * * * marks = *input.nextInt();
    * * * * * **
    * * * * * **
    * * * * * * if (marks <= 29){
    * * * * * * * * counter1++;
    * * * * * * * * students++;
    * * * * * * * **
    * * * * * * * **
    * * * * * * * **
    * * * * * * }
    * * * * * * if ( marks >= 30 && marks <=39 ){
    * * * * * * * * counter2++;
    * * * * * * * * students++;
    * * * * * * * **
    * * * * * * * **
    * * * * * * * **
    * * * * * * }
    * * * * * * if ( marks >= 40 && marks <=69 ){
    * * * * * * * * counter3++;
    * * * * * * * * students++;
    * * * * * * * * passed++;
    * * * * * * * **
    * * * * * **
    * * * * * **
    * * * * }
    * * * * * * if ( marks >= 70 && marks <=100 ){
    * * * * * * * * counter4++;
    * * * * * * * * students++;
    * * * * * * * * passed++;
    * * * * * * * **
    * * * * * * }
    * * * * * *
    * * * * if (marks <=100){
    * * * * totalmarks = totalmarks + marks;}
    * * * * * **
    * * * * if (marks > highest && marks <=100){

    * * * * highest = marks;}

    * * * * if(marks < lowest && marks >=0){

    * * * * lowest = marks;}
    * * * *


    * * }
    * * * **
    * * * **
    * * * * * * * System.out.print("0-29:");
    * * * * * * * for (int n =0;n <counter1;n++){
    * * * * * * * * * System.out.print("*");}
    * * * * * * * * **
    * * * * * * * System.out.println(" ");
    * * * * * * * * **
    * * * * * * **
    * * * * * * * *System.out.print("30-39:");
    * * * * * * * for (int n =0;n <counter2;n++){
    * * * * * * * * * System.out.print("*");}
    * * * * * * * * **
    * * * * * * * System.out.println(" ");
    * * * * * * **
    * * * * * * * System.out.print("40-69:");
    * * * * * * * for (int n =0;n <counter3;n++){
    * * * * * * * * * System.out.print("*");}
    * * * * * * *
    * * * * * * * System.out.println(" ");
    * * * * * * **
    * * * * * **
    * * * * * * * System.out.print("70-100:");
    * * * * * * * for (int n =0;n <counter4;n++){
    * * * * * * * * **
    * * * * * * * * * System.out.print("*");}
    * * * * * * **
    * * * * * * * System.out.println(" *");
    * * * * * * **
    * * * * * * **

    * * * *average = (double) (totalmarks)/ students;

    * * * *System.out.println("Highest number is: " + highest);
    * * * *System.out.println("Lowest number is: " + lowest);
    * * * *System.out.println("The average mark is : " + average);
    * * * *System.out.println("Total Number of Students took the Test : " + students);
    * * * *System.out.println("Total Number of Students Passed : " + passed);

    * }

    *}

    CODE ENDS HERE!!

  2. #2
    Join Date
    Nov 2014
    Posts
    2

    Re: Need help with displaying programme output vertically. Programme details below!

    Note that!

    *****in front of each code line is meant to be space!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured