Skip to content

Commit

Permalink
Added Task 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohaned Yossry Abdulaziz committed Dec 22, 2020
1 parent b962675 commit eceb814
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 0 deletions.
71 changes: 71 additions & 0 deletions Task3StarterProject/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
8 changes: 8 additions & 0 deletions Task3StarterProject/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Task3StarterProject/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Task3StarterProject/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Task3StarterProject/Task3StarterProject.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
75 changes: 75 additions & 0 deletions Task3StarterProject/src/Task3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

/*
TODO Task Hint:
copy this line to be able to define Scanner object that will be used to take input from user
Scanner input = new Scanner(System.in);
*/
public class Task3 {

public static void main(String[] args) {

}

/*
TODO: Question 1: (Assign grades) Write a program that reads student scores, gets the best score, and
then assigns grades based on the following scheme:
Grade is A if score is >= bestScore - 5;
Grade is B if score is >= bestScore - 10;
Grade is C if score is >= bestScore - 15;
Grade is D if score is >= bestScore - 20;
Grade is F otherwise.
The program prompts the user to enter the total number of students, and then
prompts the user to enter all of the scores, and concludes by displaying the grades.
----------------------------------------------------------------------------------
Here is a sample run:
----------------------------------------------------------------------------------
Enter the number of students: 4
Enter 4 scores: 40 55 70 58
Student 0 score is 40 and grade is F
Student 1 score is 55 and grade is C
Student 2 score is 70 and grade is A
Student 3 score is 58 and grade is C
.
*/

//TODO Write Answer for Question 1 Here


//-----------------------------------------------------------------------//

/*
TODO: Question 2: Write a program that reads ten integers, and then display the number of even numbers and odd numbers.
Assume that the input ends with 0.
----------------------------------------------------------------------------------
Here is the sample run of the program.
----------------------------------------------------------------------------------
Enter numbers: 1 2 3 2 1 6 3 4 5 2 3 6 8 9 9 0
The number of odd numbers: 8
The number of even numbers: 7
*/

//TODO Write Answer for Question 2 Here

//-----------------------------------------------------------------------//

/*
TODO: Question 3: design a class named Rectangle to represent a rectangle. The class contains:
--------------------------------------------------------------------------------
■■ Two double data fields named width and height that specify the width and
height of the rectangle. The default values are 1 for both width and height.
■■ A no-arg constructor that creates a default rectangle.
■■ A constructor that creates a rectangle with the specified width and height.
■■ A method named getArea() that returns the area of this rectangle.
■■ A method named getPerimeter() that returns the perimeter.
--------------------------------------------------------------------------------
Write a test program that creates two Rectangle objects—one with width 4 and height 40, and
the other with width 3.5 and height 35.9. Display the width, height, area, and
perimeter of each rectangle in this order
*/

//TODO Write Answer for Question 3 Here and define the class outside this class but in the same file:


//-----------------------------------------------------------------------//

}

0 comments on commit eceb814

Please sign in to comment.