Bolded statement in my code produces

Assignment Help Basic Computer Science
Reference no: EM131848608

The bolded statement in my code produces the output of 0.0 / 0 if the totalScore / totalMax produce a double. I've been trying different solution for an hour, but nothing seems to work! Any help is appreciated, thank you.

  public static double homework(Scanner console) {

   System.out.println("Please enter information about your homework:");

   System.out.println("Weight? 0-100?");

   int weight = console.nextInt();

   System.out.println("Number of assignments?");

   int assign = console.nextInt();

   int score = 0;

   int max = 0;

   for (int i = 1; i <= assign; i++) {

     System.out.println("Assignment " + i + " score and max?");

     score = score + console.nextInt();

     max = max + console.nextInt();

   }

   System.out.println("How many section did you attend?");

   int attendance = console.nextInt();

   int sectionPointsEarned = attendance * 5;

   if (sectionPointsEarned > sectionPoints) {

     sectionPointsEarned = sectionPoints;

   }

   System.out.println("Section points = " + sectionPointsEarned + "/ " + sectionPoints);

   int totalScore = score + sectionPointsEarned;

   int totalMax = max + sectionPoints;

   if (totalScore > totalMax) {

     totalScore = totalMax;

   }

   System.out.println("Total points = " + totalScore + "/ " + totalMax);

   double weightedScore = ((weight * 1.0) * (totalScore / totalMax));

   weightedScore = Math.round(weightedScore * 10.0) / 10.0;

   System.out.println("Weighted score = " + weightedScore + " / " + weight);

   System.out.println();

   return weightedScore;

  }

Reference no: EM131848608

Questions Cloud

Describe the reason for the genetic counseling : Describe the reason for the genetic counseling based on the findings from your completion of the history tool.
Advocate a mandatory expiration date : Would you advocate a mandatory expiration date on data to ensure at some point it no longer exists?
Binary floating-point representation of the number : Using a 64-bit system, the binary floating-point representation of the number a, the way that computer stores this number, is the following
Desktop or web based applications : Can we use Ms Access to prototype Desktop or Web Based Applications?
Bolded statement in my code produces : The bolded statement in my code produces the output of 0.0 / 0 if the totalScore / totalMax produce a double. I've been trying different solution
Manufactures time series photographic equipment : Photochronograph Corporation (PC) manufactures time series photographic equipment. The company raises all equity from outside financing.
Biggest challenges to being a systems : Provide some examples of what would you believe are some of the biggest challenges to being a systems analyst and explain why you feel that might be a challenge
What is the company target debt–equity ratio : If the company issued new securities in the same proportion as its target capital structure, what is the company’s target debt–equity ratio?
What characteristics make up a good network design : What characteristics make up a good network design? What would you includet?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Is there any evidence supporting this

Is there any evidence supporting this?

  Design a control panel to display a map of a building

Write structured LabVIEW program to simulate PC based security system control panel, connected to sensors and actuators in a building - Design a control panel to display a map of a building and the current state of monitored and controlled equipment..

  Contrast a business case and a business plan

Compare and contrast a Business Case and a Business Plan. Include definitions and applications.

  Healthcare in the united states became

1. What are the reasons that healthcare in the United States became (and thus far remains) so costly?

  What is the transitive closure of r

Let R be the relation {(a, b) | a divides b} on the set of integers. What is the symmetric closure of R? What is the transitive closure of R?

  Gaining market share and hiring

Sears is losing market share, has been acquired by K-Mart, and is eliminating jobs; Walmart is gaining market share and hiring.

  Hypothesis of a study is not supported by the data

What are the primary methodologies used in the four studies that you read? Did each of the studies prove or disprove their initial hypothesis? Why or why not? If the hypothesis of a study is not supported by the data, does that invalidate the stud..

  Write c++ code that rearranges the integers

Write C++ code that rearranges the integers

  What is the definition of data in second normal form

What is the rule for converting tables in second normal form to tables in third normal form? 15. What is the definition of data in third normal form?

  Discuss problem of the hash codes

Use HashCalc to check the hash codes on the two identical files. Once it is determined the two files have the same hash codes.

  An organization can use a management system

Write a 750 -ways in which an organization can use a management system to manage file and print resources for a group of Windows Servers®.

  Would you expect the mean or the median to be larger

E-mails. A university teacher saved every e-mail received from students in a large Introductory Statistics class during an entire term. He then counted, for each student who had sent him at least one e-mail, how many e-mails each student had sent.

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