Sunday, September 12, 2021

Quiz Randomizer in PHP and MySQL

 A simple quiz randomizer that I wrote using PHP and MySQL I hope you will find it useful.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.



Program Listing

index.php

<?php

    // index.php

    // Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

    // www.jakerpomperada.blogspot.com and www.jakerpomperada.com

    // jakerpomperada@gmail.com

    // Bacolod City, Negros Occidental

 

    // include database connection

    include "connection.php";


   

    $stmt = $con->prepare("SELECT * FROM `data` ORDER BY RAND()");

    $stmt->execute();

    $res = $stmt->get_result();

    $links = $slides = $options = $choices = "";

    if ($res->num_rows > 0) {

        $num = 0;

        while ($row = $res->fetch_assoc()) {

            $num++;

            $links .= '<a href="#slide-'.$num.'">'.$num.'</a>';

            

            $con1 = [1,2,3,4];

            shuffle($con1);

            for ($i=1; $i <= 4; $i++) { 

                $choice = "choice_".$con1[$i-1];

                ($i == 1)? $required="required":"";

                $options .= '

                            <input type="hidden" name="qid'.$num.'" value="'.$row["id"].'">

                            <label class="option option-'.$i.'">

                                <input type="radio" name="answer'.$num.'" class="optionbox" id="option-'.$num.$i.'" value="'.$row[$choice].'" '.$required.'>

                                <span>'.wordwrap($row[$choice], 25, "<br />\n").'</span>

                            </label>';

            }


            $slides .= '

                <div id="slide-'.$num.'">

                    <table>

                        <tr>

                            <td colspan="2">   

                                <div class="titleblock">Question #'.$num.'</div>

                                <textarea name="txtQuestion'.$row["id"].'" rows="5" placeholder="Enter question #'.$row["id"].' here..." disabled required>'.$row["question"].'</textarea>

                            </td>

                        </tr>

                        <tr>

                            <td colspan="2">

                                <div class="wrapper">

                                    '.$options.'

                                </div>

                            </td>

                        </tr>

                    </table>

                </div>

            ';

            $options = $choices = "";

        }

    } else {

        header("Location: questions.php");

    }

    $con->close();

?>

<!DOCTYPE html>

<html lang="en">

    <head>

        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Quiz | Quiz Randomizer in PHP MySQL</title>

        <link rel="stylesheet" href="styles.css">

        <style>

            .titleblock,

            table th div,

            button,

            .slider .links>a {

                background: #2196f3!important;

            }

        </style>

    </head>

    <body>

        <main>

            <form method="post" action="result.php">

                <div class="title">

                    <h1>Quiz Randomizer in PHP MySQL</h1>

                    <h2>&#187; Jake R. Pomperada, MAED-IT, MIT &#171;</h2>

                    <br>

                    <hr>

                    <h3>Quiz</h3>

                    <hr>

                </div>

                <div class="slider">

                    <div class="links">

                        <?php echo $links; ?>

                    </div>

                    <div class="slides">

                        <?php echo $slides; ?>

                    </div>


                    <button type="submit" name="btnSubmit" class="btnSubmit">Submit</button>

                </div>

            </form>

        </main>

    </body>

</html>


connection.php

<?php

    // Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

    // www.jakerpomperada.blogspot.com and www.jakerpomperada.com

    // jakerpomperada@gmail.com

    // Bacolod City, Negros Occidental

    


    // Enable error reporting for mysqli

    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);


    // Hostname

    $host = "localhost";


    // Username

    $user = "root";


    // Password

    $pass = "";


    // Database Name

    $db   = "r_questions";


    // Establish database connection

    $con = new mysqli($host, $user, $pass, $db);

    if ($con->connect_error) {

        die("Connection failed: " . $con->connect_error);

    }


questions.php

<?php

   // Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

    // www.jakerpomperada.blogspot.com and www.jakerpomperada.com

    // jakerpomperada@gmail.com

    // Bacolod City, Negros Occidental

    // include database connection


    include "connection.php";

    $message = "";


    if(isset($_POST["btnSubmit"])) {

        for ($i=1; $i < 5; $i++) { 

            $qn = "txtQuestion".$i;

            $c1 = "txtChoice".$i."1";

            $c2 = "txtChoice".$i."2";

            $c3 = "txtChoice".$i."3";

            $c4 = "txtChoice".$i."4";

            $ans = "txtAnswer".$i;

            $stmt_check = $con->prepare("SELECT `id` FROM `data` WHERE `id`=?");

            $stmt_check->bind_param("i", $i);

            $stmt_check->execute();

            $stmt_check->store_result();

            if($stmt_check->num_rows > 0) {

                $stmt = $con->prepare("UPDATE `data` SET `question`=?,`choice_1`=?,`choice_2`=?,`choice_3`=?,`choice_4`=?,`answer`=? WHERE `id`=?");

                $stmt->bind_param("sssssii", $_POST[$qn], $_POST[$c1], $_POST[$c2], $_POST[$c3], $_POST[$c4], $_POST[$ans], $i);

                $message = '<div class="message update">Record Successfully Updated</div>';

            } else {

                $stmt = $con->prepare("INSERT INTO `data`(`question`, `choice_1`, `choice_2`, `choice_3`, `choice_4`, `answer`) VALUES (?,?,?,?,?,?)");

                $stmt->bind_param("sssssi", $_POST[$qn], $_POST[$c1], $_POST[$c2], $_POST[$c3], $_POST[$c4], $_POST[$ans]);

                $message = '<div class="message save">Record Successfully Saved</div>';

            }

            $stmt->execute();

            $stmt->close();

        }

    }


    $stmt = $con->prepare("SELECT * FROM `data`");

    $stmt->execute();

    $res = $stmt->get_result();

    $links = $slides = $options = $choices = "";

    if ($res->num_rows > 0) {

        while ($row = $res->fetch_assoc()) {

            for ($i=1; $i <= 4; $i++) { 

                $i == $row["answer"]? $selected ="selected": $selected = ""; 

                $options .= '<option value="'.$i.'" '.$selected.'>Choice #'.$i.'</option>';

                $choice = "choice_".$i;

                $choices .= '<tr>

                                <th><div>Choice #'.$i.':</div></th>

                                <td><input type="text" name="txtChoice'.$row["id"].$i.'" placeholder="Enter choice #'.$i.' here..." value="'.$row[$choice].'" required></td>

                            </tr>';

            }


            $links .= '<a href="#slide-'.$row["id"].'">'.$row["id"].'</a>';


            $slides .= '

                <div id="slide-'.$row["id"].'">

                    <table>

                        <tr>

                            <td colspan="2">   

                                <div class="titleblock">Question #'.$row["id"].'</div>

                                <textarea name="txtQuestion'.$row["id"].'" rows="5" placeholder="Enter question #'.$row["id"].' here..." required>'.$row["question"].'</textarea>

                            </td>

                        </tr>

                        '.$choices.'

                        <tr>

                            <th><div>Answer:</div></th>

                            <td>

                                <select name="txtAnswer'.$row["id"].'" required>

                                    '.$options.'

                                </select>

                            </td>

                        </tr>

                    </table>

                </div>

            ';

            $options = $choices = "";

        }

    } else {

        $message = '<div class="message error"><b>ERROR:</b> No Questions to display. Please add some questions first.</div>';


        for ($reps=1; $reps < 5; $reps++) {

            $links .= '<a href="#slide-'.$reps.'">'.$reps.'</a>';


            for ($i=1; $i <= 4; $i++) { 

                $options .= '<option value="'.$i.'">Choice #'.$i.'</option>';

                $choice   = "choice_".$i;

                $choices .= '<tr>

                                <th><div>Choice #'.$i.':</div></th>

                                <td><input type="text" name="txtChoice'.$reps.$i.'" placeholder="Enter choice #'.$i.' here..." required></td>

                            </tr>';

            }


            $slides .= '

                <div id="slide-'.$reps.'">

                    <table>

                        <tr>

                            <td colspan="2">   

                                <div class="titleblock">Question #'.$reps.'</div>

                                <textarea name="txtQuestion'.$reps.'" rows="5" placeholder="Enter question #'.$reps.' here..." required></textarea>

                            </td>

                        </tr>

                        '.$choices.'

                        <tr>

                            <th><div>Answer:</div></th>

                            <td>

                                <select name="txtAnswer'.$reps.'" required>

                                    <option value="" selected disabled>~ Select Answer ~</option>

                                    '.$options.'

                                </select>

                            </td>

                        </tr>

                    </table>

                </div>

            ';

            $options = $choices = "";

        }

    }

    $con->close();

?>

<!DOCTYPE html>

<html lang="en">

    <head>

        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Questions | Quiz Randomizer in PHP MySQL</title>

        <link rel="stylesheet" href="styles.css">

    </head>

    <body>

        <?php echo $message; ?>

        <main>

            <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">

                <div class="title">

                    <h1>Quiz Randomizer in PHP MySQL</h1>

                    <h2>&#187; Jake R. Pomperada, MAED-IT, MIT &#171;</h2>

                    <br>

                    <hr>

                    <h3>Questions</h3>

                    <hr>

                </div>

                <div class="slider">

                    <div class="links">

                        <?php echo $links; ?>

                    </div>

                    <div class="slides">

                        <?php echo $slides; ?>

                    </div>

                    <div class="btnWrapper">

                        <button type="submit" name="btnSubmit" class="btnHalf btnSubmit">Save Entries</button>

                        <a href="index.php" class="btnHalf btnQuiz">Take the Quiz!</a>

                    </div>

                </div>

            </form>

        </main>

    </body>

</html>


result.php

<?php

     // Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

    // www.jakerpomperada.blogspot.com and www.jakerpomperada.com

    // jakerpomperada@gmail.com

    // Bacolod City, Negros Occidental

    // include database connection


    include "connection.php";

    $key = [];

    $num = 0;

    if(isset($_POST["btnSubmit"])) {

        for ($i=1; $i < 5; $i++) { 

            $stmt = $con->prepare("SELECT * FROM `data` WHERE `id`=?");

            $stmt->bind_param("i", $_POST["qid".$i]);

            $stmt->execute();

            $res = $stmt->get_result();

            while ($row = $res->fetch_assoc()){

                for ($x=1; $x < 5; $x++) {

                    if ($_POST["answer".$i] == $row["choice_".$x]) {

                        ($row["answer"] == $x)? $num++:"";

                    }

                }

            }

            $stmt->close();

        }

    }

    $con->close();

?>

<!DOCTYPE html>

<html lang="en">

    <head>

        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Result | Quiz Randomizer in PHP MySQL</title>

        <link rel="stylesheet" href="styles.css">

    </head>

    <body>

        <main>

            <div class="title">

                <h1>Quiz Randomizer in PHP MySQL</h1>

                <h2>&#187; Jake R. Pomperada, MAED-IT, MIT &#171;</h2>

                <br>


                <hr>

                <h3>Result</h3>

                <hr>


                <h1 class="txtScore">Score: <?php echo ($num*25)."%"; ?></h1>


                <div class="btnWrapper">

                    <a href="questions.php" class="btnHalf btnSubmit">Back to Questions</a>

                    <a href="index.php" class="btnHalf btnQuiz">Take the Quiz Again?</a>

                </div>

            </div>

        </main>

    </body>

</html>


style.css

@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');


:root {

    --width: 400px;

    --height: auto;

    --maincolor: #ED4264;

}


* {

    box-sizing: border-box;

    margin: 0;

    padding: 0;

}


html,

body {

    height: 100%;

    text-align: center;

}


body {

    background: #fff;


    font-family: 'Poppins', sans-serif;

    min-height: 100vh;

    overflow-x: hidden;

}


main {

    padding: 100px 0;

    display: flex;

    align-items: center;

    justify-content: center;

}


.title {

    display: block;

    margin: 0 0 30px;

    text-align: center;

    color: #000;

}


h1 {

    font-size: 25px;

    line-height: 25px;

    text-transform: uppercase;

    margin: 0 0 5px 0;

}


h2 {

    font-size: 20px;

    margin: 0 0 10px 0;

}


.slider {

    width: var(--width);

    text-align: center;

    overflow: hidden;

    display: block;

    margin: 0 auto;

}


.slider>.links {

    position: absolute;

    left: calc(50% - 242px);

    align-items: center;

    z-index: 9999;

}


.slider .links>a {

    background: var(--maincolor);

    text-align: center;

    text-decoration: none;

    display: block;

    padding: 20px 15px;

    color: #fff;

    margin-bottom: 2px;

}


.slider .links>a:focus {

    background: #000;

}


.slides {

    display: flex;

    overflow-x: hidden;

    scroll-snap-type: x mandatory;

    scroll-behavior: smooth;

    -webkit-overflow-scrolling: touch;

}


.slides>div {

    scroll-snap-align: start;

    flex-shrink: 0;

    width: var(--width);

    height: var(--height);

    margin-right: 50px;

    background: #eee;

    transform-origin: center center;

    transform: scale(1);

    transition: transform 0.5s;

    position: relative;


    display: flex;

    justify-content: center;

    align-items: center;

    /* font-size: 100px; */


    padding: 30px;

}


.titleblock {

    display: block;

    width: 100%;

    text-align: center;

    padding: 20px;

    color: #f1f1f1;

    text-transform: uppercase;

}


table th {

    vertical-align: top;

}


table th div {

    display: block;

    text-transform: uppercase;

    color: #f1f1f1;

    text-align: center;

    padding: 10px;

}


table td {

    white-space: nowrap;

}



textarea,

select,

input {

    font-family: 'Poppins', sans-serif;

    display: block;

    background: #e1e1e1;

    width: 100%;

    padding: 10px;

    border: none;

    font-size: 15px;

    resize: none;

}


input:hover,

input:focus,

select:hover,

select:focus,

textarea:hover,

textarea:focus {

    background: #dbdbdb;

}


textarea,

input {

    margin-bottom: 5px;

}


.btnWrapper {

    display: inline-flex;

}


.btnblock {

    display: flex;

}


.txtScore {

    margin: 80px 0;

    font-size: 50px;

    line-height: 1.2;

}


.btnQuiz,

.btnSubmit,

button {

    font-family: 'Poppins', sans-serif;

    color: #fff;

    padding: 15px;

    opacity: 0.9;

    outline: none;

    font-size: 20px;

    text-transform: uppercase;

    border: none;

    text-align: center;

    cursor: pointer;

    text-decoration: none;

    display: block;

    margin: 2px 0 0;

}


.btnSubmit {

    width: var(--width);

}


.btnQuiz,

.btnSubmit,

button:hover {

    opacity: 1;

}


.titleblock,

table th div,

.btnSubmit,

.btnQuiz,

button {

    background: var(--maincolor);

    font-weight: bold;

    font-size: 15px;

}


.btnWrapper {

    display: flex;

    padding: 0;

    margin: 0;

}


.btnHalf {

    width: 50%;

}


.btnQuiz {

    background: #2196f3;

}


.wrapper {

    background: #fff;

    width: 300px;

    border-radius: 5px;

    padding: 10px;

    display: block;

}


.wrapper .option {

    background: #fff;

    width: 100%;

    border-radius: 5px;

    cursor: pointer;

    border: 2px solid lightgrey;

    transition: all 0.3s ease;

    margin-bottom: 5px;

    display: block;

    text-align: left;

    display: flex;

    align-items: center;

}


.wrapper .option:last-child {

    margin-bottom: 0;

}


input[type="radio"] {

    display: inline-block;

    height: 14px;

    width: 14px;

    margin: 0 10px;

    padding: 0;

}


.wrapper .option span {

    display: inline-block;

    font-size: 18px;

    color: #808080;

    width: calc(100% - 32px);

    white-space: nowrap;

}


.message {

    position: fixed;

    top: 20px;

    left: calc(50% - 200px);

    width: 400px;

    padding: 20px;

    text-align: center;

    -webkit-animation: cssAnimation 0s ease-in 4s forwards;

    animation: cssAnimation 0s ease-in 4s forwards;

    -webkit-animation-fill-mode: forwards;

    animation-fill-mode: forwards;

    color: #fff;

}


@keyframes cssAnimation {

    to {

        width:0;

        height:0;

        overflow:hidden;

        padding: 0;

    }

}

@-webkit-keyframes cssAnimation {

    to {

        width:0;

        height:0;

        visibility:hidden;

        padding: 0;

    }

}


.message.update {

    background: #ffc107;

    color: #000;

}


.message.save {

    background: #4caf50;

}


.message.error {

    background: #f44336;

}


r_questions.sql

-- phpMyAdmin SQL Dump

-- version 5.0.3

-- https://www.phpmyadmin.net/

--

-- Host: 127.0.0.1

-- Generation Time: Sep 11, 2021 at 11:44 PM

-- Server version: 10.4.14-MariaDB

-- PHP Version: 7.4.11


SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

START TRANSACTION;

SET time_zone = "+00:00";



/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8mb4 */;


--

-- Database: `r_questions`

--


-- --------------------------------------------------------


--

-- Table structure for table `data`

--


CREATE TABLE `data` (

  `id` int(11) NOT NULL,

  `question` varchar(500) NOT NULL,

  `choice_1` text NOT NULL,

  `choice_2` text NOT NULL,

  `choice_3` text NOT NULL,

  `choice_4` text NOT NULL,

  `answer` int(11) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


--

-- Dumping data for table `data`

--


INSERT INTO `data` (`id`, `question`, `choice_1`, `choice_2`, `choice_3`, `choice_4`, `answer`) VALUES

(1, '1 + 1 = ?', '2', '3', '4', '5', 1),

(2, '2+2=?', '6', '8', '10', '4', 4),

(3, 'Highest Mountain in the World.', 'Mt. Carmel', 'Mt. Liza', 'Mt. Everest', 'Mt. John', 3),

(4, 'Latest version of Microsoft Windows?', 'Window XP', 'Windows 10', 'Windows 11', 'Windows 95', 3);


--

-- Indexes for dumped tables

--


--

-- Indexes for table `data`

--

ALTER TABLE `data`

  ADD PRIMARY KEY (`id`);


--

-- AUTO_INCREMENT for dumped tables

--


--

-- AUTO_INCREMENT for table `data`

--

ALTER TABLE `data`

  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

COMMIT;


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;




Friday, September 10, 2021

Sum of Two Numbers Using JOptionPane in Java

Sum of Two Numbers Using JOptionPane in Java

 A simple addition of two numbers using Java that using swing JOptionPane to accept and display the sum of the two numbers.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.




Program Listing

// Addition,java

// Addition program that uses JOptionPane for input and output.

// Jake Rodriguez Pomperada, MAED-IT, MIT

// www.jakerpomperada.blogspot.com  and www.jakerpomperada.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental Philippines


import javax.swing.JOptionPane; 


public class Addition 

{

   public static void main( String args[] )

   {

      // obtain user input from JOptionPane input dialogs

      String x = 

         JOptionPane.showInputDialog( "Enter first integer" );

      String y =

          JOptionPane.showInputDialog( "Enter second integer" );


      // convert String inputs to int values for use in a calculation

      int a = Integer.parseInt(x); 

      int b = Integer.parseInt(y);


      // Perform addition of variables a and variable b

      int sum = a+b;


      // display result in a JOptionPane message dialog

      JOptionPane.showMessageDialog( null, "The sum of " + a + " and " + b + " is " + sum + ".", 

         "Sum of Two Numbers Using JOptionPane in Java", JOptionPane.INFORMATION_MESSAGE );

   } // end method main

} // end class Addition



Thursday, September 9, 2021

Three Dimensional Arrays in C++

Three Dimensional Array in C++

 A simple program to demonstrate how to declare and use three dimensional arrays in C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.





Program Listing

#include <iostream>

#include <vector>

#include <cassert>


template<class T>

class Array3D

{

  std::vector<T> data;

  size_t m_dim1, m_dim2, m_dim3;

public:

  Array3D(size_t dim1, size_t dim2, size_t dim3):

    m_dim1(dim1), m_dim2(dim2), m_dim3(dim3)

  {

    assert(m_dim1 > 1 && m_dim2 > 1 && m_dim3 > 1);

    data.resize(m_dim1 * m_dim2 * m_dim3);

  }

  T& operator()(size_t d1, size_t d2, size_t d3)

  {

    assert(d1 < m_dim1 && d2 < m_dim2 && d3 < m_dim3);

    return data[d1*d2*m_dim3 + d2*m_dim3 + d3];

  }

  const T& operator()(size_t d1, size_t d2, size_t d3) const

  {

    assert(d1 < m_dim1 && d2 < m_dim2 && d3 < m_dim3);

    return data[d1*d2*m_dim3 + d2*m_dim3 + d3];

  }

  size_t dim1() {return m_dim1;}

  size_t dim2() {return m_dim2;}

  size_t dim3() {return m_dim3;}

};


int main()

{

  Array3D<int> array3d(2,2,2);


  for ( size_t d1=0; d1 < 2; ++d1 )

  {

    for ( size_t d2=0; d2 < 2; ++d2 )

    {

      for ( size_t d3=0; d3 < 2; ++d3 )

      {

        array3d(d1,d2,d3) = 3;

      }

    }

  }


  array3d(1,1,1) = -99;


  std::cout << "Three Dimensional Arrays in C++";

  std::cout << "\n\n";

  for ( size_t d1=0; d1 < 2; ++d1 )

  {

    for ( size_t d2=0; d2 < 2; ++d2 )

    {

      for ( size_t d3=0; d3 < 2; ++d3 )

        std::cout << "array3d["<< d1 << "][" << d2 << "][" << d3 << "] = " << array3d(d1, d2, d3) << "\n";

    }

  }

}

Wednesday, September 8, 2021

Person's Age Checker in C

PERSONS AGE CHECKER IN C

A simple program to check the age of the person whether the person is already an adult or still a minor using C programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.




 

Program Listing

/* Persons Age Checker in C */

/* Author  : Mr. Jake R. Pomperada, MAED-IT   */

/* Date    : March 1, 2017  Wednesday         */

/* Tools   : CodeBlocks 16.1                  */

/* Country : Philippines                      */



#include <stdio.h>


int age = 0;


int main()

{

    printf("\n\n");

    printf("\t===== PERSONS AGE CHECKER IN C =====");

    printf("\n\n");

    printf("\tWhat is your age : ");

    scanf("%d",&age);


    if (age >= 18 ) {

        printf("\n\n");

        printf("\tAt the age of %d years old you are already an ADULT.",age);

      }


    else {

        printf("\n\n");

        printf("\tAt the age of %d years old you are still a MINOR.",age);

      }

    printf("\n\n");

    printf("\tEND OF PROGRAM");

    printf("\n\n");

}



How To Run a Java Program Using BlueJ

Tuesday, September 7, 2021

Average Grade Solver in Java Using BlueJ

Average Grade Solver in Java Using BlueJ

  Machine Problem

Create a simple average solver of your grades. Then identify the grades whether pass or fail.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.







Program Listing

/* Average_Grade,java

 * Author : Jake Rodriguez Pomperada, MAED-IT, MIT

 * September 7, 2021   Tuesday   6:01 AM

 * www.jakerpomperada.blogspot.com  and www.jakerpomperada.com

 * jakerpomperada@gmail.com

 * Bacolod City, Negros Occidental Philippines.

 * 

 * Machine Problem

 * 

 * Create a simple average solver of your grades. Then identify the grades

 * whether pass or fail.

 */

import java.util.Scanner;

import java.math.RoundingMode;

import java.text.DecimalFormat;

 

public class Average_Grade {

    

     private static DecimalFormat df2 = new DecimalFormat("#.##");

     

 public static void main(String[] args) {

     

      Scanner input = new Scanner(System.in);

    

   System.out.print("Enter Subject: ");

  String subject = input.nextLine();

   

  System.out.print("Enter Prelim Grade: ");

  double prelim = input.nextDouble();

   

  System.out.print("Enter Midterm Grade: ");

  double midterm = input.nextDouble();

   

  System.out.print("Enter Final Grade: ");

  double final_grade = input.nextDouble();

   

  double average_grade = (prelim+midterm+final_grade)/3;

    

  if (average_grade >= 75) {

         

       System.out.println();

       df2.setRoundingMode(RoundingMode.DOWN);

       System.out.println("Your Final Grade is " + df2.format(average_grade) + "\n");

       System.out.print("You were successful in your " + subject + " class.");

  } else {

       System.out.println();

       df2.setRoundingMode(RoundingMode.DOWN);

       System.out.println("Your Final Grade is " + df2.format(average_grade) + "\n");

       System.out.print("You failed the " + subject + " subject.");

  }

  

 }

}




Sunday, September 5, 2021

Union Sample Program in C

Union Sample Program in C

 A simple program to demonstrate how to declare and use union in C programming language.

 am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.





Program Listing

/* unio.c
   Author : Professor Jake Rodriguez Pomperada, MAED-IT, MIT
   www.jakerpomperada.blogspot.com  and  www.jakerpomperada.com 
   jakerpomperada@gmail.com
   Bacolod City, Negros Occidental Philippines.
*/

#include <stdio.h>

union student
{
   char name[200],subject[200];
   int age;
   float grade;
};

int main()
{
 union student records;
 printf("\n\n");
 printf("\tUnion Sample Program in C");
 printf("\n\n");
 printf("\t===== DISPLAY RECORD =====");
 printf("\n\n");
 strcpy(records.name,"Jacob Samuel F. Pomperada");
 printf("\tStudent Name    :  %s\n ",records.name);
 records.age = 17;
 printf("\tStudent Age     :  %d\n ",records.age);
 strcpy(records.subject,"Linear Algebra");
 printf("\tStudent Subject :  %s\n ",records.subject);
 records.grade =89.03;
 printf("\tStudent Grade   :  %.2f\n ",records.grade);
 printf("\n");
 printf("\tEnd of Program");
 printf("\n\n");
}

Saturday, September 4, 2021

Student Grade Solver in AngularJS

Student Grade Solver in AngularJS

 Machine Problem

Write a program that will ask user to give the student name, subject, prelim grade, midterm grade, and end term grade. The program will display the student name, subject and compute the final grade of the student in the particular subject.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.





Program Listing

<!-- index.htm

  Author   : Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

  Date     : July 24, 2021  Saturday 2:14 PM

  Place    : Bacolod City, Negros Occidental

  Websites : www.jakerpomperada.com and www.jakerpomperada.blogspot.com

  Email    : jakerpomperada@gmail.com

 -->

<html>

  <head>

    <title>Student Grade Solver in AngularJS</title>

  <script type="text/javascript" src="angular.min.js"></script>

     <script>

    var myApp=angular.module("myModule",[]);

    myApp.controller("Compute_Grade",function($scope) {

    $scope.SolveGrade=function()

    {

           

         compute_grade =  ($scope.prelim * 0.20) +  

                           ($scope.midterm * 0.30) +

                           ($scope.endterm * 0.50);


        $scope.title="===== Student Grade Report =====";

         $scope.student = "Student Name  : " + $scope.student_name;

         $scope.subject = "Subject       : " + $scope.subject_name; 

         $scope.final_grade =   "Final Grade   : " + compute_grade.toFixed(0);

       }



    });

     </script>

     

 </head>

 <style>

body {

font-family: arial;

font-size: 25px;

font-weight: bold;

}

</style>

 <body ng-app="myModule" ng-controller="Compute_Grade">

  <h3>Student Grade Solver in AngularJS</h3>

 <div>

  <table border="0">

  <tr>

  <td>

  Enter Student Name  </td>

       <td>

        &nbsp;&nbsp;&nbsp;&nbsp;

         <input type="text"  size="40" ng-model="student_name" required/>

       </td>

      <tr>

  <td>

  Enter Subject Name </td>

       <td>

        &nbsp;&nbsp;&nbsp;&nbsp;

         <input type="text" size="40" ng-model="subject_name" 

         required/>

       </td>   

       </tr>

       <tr>

         <td>&nbsp;&nbsp;&nbsp;</td>

        </tr>

       <tr>

       <td>

      Enter Prelim Grade </td>

       <td>

        &nbsp;&nbsp;&nbsp;&nbsp;

         <input type="number" ng-model="prelim"/>

       </td>   

       </tr>

       <tr>

       <td>

      Enter Midterm Grade </td>

       <td>

        &nbsp;&nbsp;&nbsp;&nbsp;

         <input type="number" ng-model="midterm"/>

       </td>   

       </tr>

       <tr>

       <td>

      Enter Endterm Grade </td>

       <td>

        &nbsp;&nbsp;&nbsp;&nbsp;

         <input type="number" ng-model="endterm"/>

       </td>   

       </tr>

       <tr>

         <td>&nbsp;&nbsp;&nbsp;</td>

        </tr>

      <tr>

      <td colspan="5">

      <input type="button" ng-click="SolveGrade()"

          title="Click here to solve the student grade."

      value="Solve Student Grade"/>

      </td>

      </tr>

      </table>

      <br>

       {{ title }} <br><br>

       {{ student | uppercase }} <br>

       {{ subject | uppercase }} <br><br>

       {{ final_grade }} 

     </div><br>

       </div>

    </body>

</html>

Thursday, September 2, 2021

Subtract Two Numbers Using a Functions in C

Substract Two Numbers Using Function in C

  A simple program to ask the user to give two numbers and then the program will subtract the difference of two numbers using functions in C programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.




Program Listing

/* subtract.c

 Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

 www.jakerpomperada.com and www.jakerpomperada.blogspot.com

 jakerpomperada@gmail.com

 Bacolod City, Negros Occidental Philippines */


#include <stdio.h>


int substract(int a, int b)

{

int diff=0;

if (a>b) {

diff = a-b;

} else{

diff = b-a;

}

return(diff);

}


int main() {

int x=0,y=0;

printf("\n\n");

printf("\tSubstract Two Numbers Using A Function in C");

    printf("\n\n");

printf("\tEnter Two Numbers : ");

scanf("%d%d",&x,&y);

    printf("\n\n");

    printf("\tThe difference between %d and %d is %d.",

x,y,substract(x,y));

printf("\n\n");

printf("\tEnd of Program");

printf("\n\n");


}



Subtract Two Numbers Using Functions in C++