Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Colombo
YEYE 3 in 1 Instant Coffee Mix 50 Sachet
Romeshka
Updated:
Today at 12:16 AM
Colombo
Red Hat Certified System Administrator (RHCSA) - RHEL 10
Sanjeewani95
Updated:
Friday at 7:43 PM
NURSING , CAREGIVER , HOTEL & BEAUTY COURSES
IVA Para Medical Campus
Updated:
Thursday at 9:24 AM
Handmade Character Soft Toys Peppa Pig Family
anil1961
Updated:
Jul 1, 2026
Ad icon
Video Content Creator
pramukag
Updated:
Jun 28, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
NEED HELP..!!! C++ wikara
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="yrollgayanth" data-source="post: 7596796" data-attributes="member: 121733"><p>Machan here is a part of the code, but this is done by java. U can use same method in C++ by changing few syntax. i'll put the rest soon</p><p></p><p>[CODE]package average;</p><p></p><p>import java.util.Scanner;</p><p></p><p>public class Main {</p><p></p><p> public static void main(String[] args) {</p><p></p><p> Scanner in = new Scanner(System.in);</p><p> double T1, T2, T3, T4;</p><p></p><p> // Test 1 of 30%</p><p> System.out.print("Please enter test 1 marks :");</p><p> T1 = in.nextDouble();</p><p></p><p></p><p> while (T1 > 100 || T1 < 0) {</p><p> System.out.print("Invalid.Please re-enter test 1 marks :");</p><p> T1 = in.nextDouble();</p><p> }</p><p></p><p> // Test 2 of 30%</p><p> System.out.print("Please enter test 2 marks :");</p><p> T2 = in.nextDouble();</p><p></p><p> while (T2 > 100 || T2 < 0) {</p><p> System.out.print("Invalid.Please re-enter test 2 marks :");</p><p> T2 = in.nextDouble();</p><p> }</p><p></p><p> //Test 3 of 30%</p><p> System.out.print("Please enter test 3 marks :");</p><p> T3 = in.nextDouble();</p><p></p><p></p><p> while (T3 > 100 || T3 < 0) {</p><p> System.out.print("Invalid.Please re-enter test 3 marks :");</p><p> T3 = in.nextDouble();</p><p> }</p><p></p><p> //Test 4 of 30%</p><p> System.out.print("Please enter test 4 marks :");</p><p> T4 = in.nextDouble();</p><p></p><p> while (T4 > 100 || T4 < 0) {</p><p> System.out.print("Invalid.Please re-enter test 4 marks :");</p><p> T4 = in.nextDouble();</p><p> }</p><p></p><p> // Calculate the final for 1st four tests</p><p> double final1 = ((T1 + T2 + T3 + T4) / 4) * 0.3;</p><p></p><p> System.out.println("Grade from first 4 tests:" + final1 + "%");</p><p></p><p></p><p> // Mid term test</p><p> System.out.print("Please enter mid-term test marks :");</p><p> double midT = in.nextDouble();</p><p></p><p> while (midT > 100 || midT < 0) {</p><p> System.out.print("Invalid.Please re-enter mid-term marks :");</p><p> midT = in.nextDouble();</p><p> }</p><p></p><p> double midTper = midT * 0.2;</p><p> System.out.println("Mid term test percentage:" + midTper);</p><p></p><p> // Final term test</p><p> System.out.print("Please enter final test marks :");</p><p> double finalT = in.nextDouble();</p><p></p><p> while (finalT > 100 || finalT < 0) {</p><p> System.out.print("Invalid.Please re-enter final tests marks :");</p><p> }</p><p></p><p> double finalper = finalT * 0.2;</p><p> System.out.print("Final test percentage :" + finalper);</p><p></p><p></p><p></p><p> }</p><p>}</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="yrollgayanth, post: 7596796, member: 121733"] Machan here is a part of the code, but this is done by java. U can use same method in C++ by changing few syntax. i'll put the rest soon [CODE]package average; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); double T1, T2, T3, T4; // Test 1 of 30% System.out.print("Please enter test 1 marks :"); T1 = in.nextDouble(); while (T1 > 100 || T1 < 0) { System.out.print("Invalid.Please re-enter test 1 marks :"); T1 = in.nextDouble(); } // Test 2 of 30% System.out.print("Please enter test 2 marks :"); T2 = in.nextDouble(); while (T2 > 100 || T2 < 0) { System.out.print("Invalid.Please re-enter test 2 marks :"); T2 = in.nextDouble(); } //Test 3 of 30% System.out.print("Please enter test 3 marks :"); T3 = in.nextDouble(); while (T3 > 100 || T3 < 0) { System.out.print("Invalid.Please re-enter test 3 marks :"); T3 = in.nextDouble(); } //Test 4 of 30% System.out.print("Please enter test 4 marks :"); T4 = in.nextDouble(); while (T4 > 100 || T4 < 0) { System.out.print("Invalid.Please re-enter test 4 marks :"); T4 = in.nextDouble(); } // Calculate the final for 1st four tests double final1 = ((T1 + T2 + T3 + T4) / 4) * 0.3; System.out.println("Grade from first 4 tests:" + final1 + "%"); // Mid term test System.out.print("Please enter mid-term test marks :"); double midT = in.nextDouble(); while (midT > 100 || midT < 0) { System.out.print("Invalid.Please re-enter mid-term marks :"); midT = in.nextDouble(); } double midTper = midT * 0.2; System.out.println("Mid term test percentage:" + midTper); // Final term test System.out.print("Please enter final test marks :"); double finalT = in.nextDouble(); while (finalT > 100 || finalT < 0) { System.out.print("Invalid.Please re-enter final tests marks :"); } double finalper = finalT * 0.2; System.out.print("Final test percentage :" + finalper); } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Haya warak paha keeyada? (haya wadi kireema paha)
Post reply
Top
Bottom