Question : Write a program to create class "time" with data members hours,minute and second ,then add two "time" objects by taking as argument and also returning object as an argument.
Solution :
#include"pch.h"
#include<iostream>
#include<conio.h>
class time
{
public:
time();
~time();
void setData();
void display();
time addTime( time);
private:
int hour, minute, second;
};
time::time()
{
hour = 0;
minute = 0;
second = 0;
}
time::~time()
{
}
void time::setData()
{
std::cout << "Enter Hour : ";
std::cin >> hour;
std::cout << "Enter Minute : ";
std::cin >> minute;
std::cout << "Enter Second : ";
std::cin >> second;
}
void time::display()
{
std::cout << "\nHour = " << hour << "\tMinute = " << minute << "\tSecond = " << second;
}
time time::addTime( time t2)
{
time temp;
temp.hour = hour + t2.hour;
temp.minute = minute + t2.minute;
temp.second = second + t2.second;
return time(temp);
}
int main() {
time t1, t2, t3;
t1.setData();
t2.setData();
t3 = t1.addTime(t2);
t3.display();
return(0);
}
Output:
This blog tell user about daily facing problem in technology field, about programming language projects,what is and how to solve the problem and about programming language.
Saturday, January 12, 2019
Saturday, December 8, 2018
flashlight application for android, code
Description:
This is android application developed in android studio using java and XML programming language.Here is ImageView which is used to get device camera permission after on click and a button which is used to ON/OFF the flash of device.
- IDE used => Android studio 3.1.0
- photo used:
drawable
(i)photo
name =btn_switch_off.PNG
(ii)photo
name =btn_switch_on.PNG
(iii)photo
name =icon.PNG
(iv)photo
name =wall.PNG
- AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dell.flashlight">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<application android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:roundIcon="@drawable/icon"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dell.flashlight">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<application android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:roundIcon="@drawable/icon"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Java class
class 1 :MainActivity.class :
package com.example.dell.flashlight;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private Button buttonEnable;
private ImageView imageFlashlight;
private static final int CAMERA_REQUEST = 50;
private boolean flashLightStatus = false;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonEnable =(Button)findViewById(R.id.buttonEnable);
imageFlashlight =(ImageView)findViewById(R.id.imageFlashlight);
final boolean hasCameraFlash = getPackageManager().
hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
boolean isEnabled = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED;
buttonEnable.setEnabled(!isEnabled);
imageFlashlight.setEnabled(isEnabled);
buttonEnable.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
ActivityCompat.requestPermissions(MainActivity.this, new String[] {Manifest.permission.CAMERA}, CAMERA_REQUEST);
}
});
imageFlashlight.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
if (hasCameraFlash) {
if (flashLightStatus)
flashLightOff();
else flashLightOn();
} else {
Toast.makeText(MainActivity.this, "No flash available on your device",
Toast.LENGTH_SHORT).show();
}
}
});
}
private void flashLightOn() {
CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
String cameraId = cameraManager.getCameraIdList()[0];
cameraManager.setTorchMode(cameraId, true);
flashLightStatus = true;
imageFlashlight.setImageResource(R.drawable.btn_switch_on);
} catch (CameraAccessException e) {
}
}
private void flashLightOff() {
CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
String cameraId = cameraManager.getCameraIdList()[0];
cameraManager.setTorchMode(cameraId, false);
flashLightStatus = false;
imageFlashlight.setImageResource(R.drawable.btn_switch_off);
} catch (CameraAccessException e) {
}
}
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch(requestCode) {
case CAMERA_REQUEST :
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
buttonEnable.setEnabled(false);
buttonEnable.setText("Camera Enabled");
imageFlashlight.setEnabled(true);
} else {
Toast.makeText(MainActivity.this, "Permission Denied for the Camera", Toast.LENGTH_SHORT).show();
}
break;
}
}
}
layout
layout 1:activity_main.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/wall"tools:context=".MainActivity"> <ImageView android:id="@+id/imageFlashlight"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:src="@drawable/btn_switch_off"android:contentDescription="@string/todo" /> <Button android:id="@+id/buttonEnable"android:layout_width="200dp"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:textSize="20sp"android:text="@string/enable_camera"android:textStyle="bold|italic"android:background="#000000"android:textColor="#ffffff"android:layout_above="@id/imageFlashlight"android:layout_marginBottom="40dp"/> </RelativeLayout>
values
1.color.xml
<?xml version="1.0" encoding="utf-8"?><resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
2.strings.xml<resources> <string name="app_name">flashlight</string> <string name="enable_camera">Enable Camera</string> <string name="todo">TODO</string> </resources>
3.styles.xml<resources> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> </resources>
dependencies
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'implementation 'com.android.support.constraint:constraint-layout:1.1.3'testImplementation 'junit:junit:4.12'androidTestImplementation 'com.android.support.test:runner:1.0.2'androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Monday, August 20, 2018
Datatype in JAVA programming language?
Datatype in java programming language
There are mainly two type of datatype:
They are of two types:
explanation
Data type Size Default Range
There are mainly two type of datatype:
- Primitive
- Non-primitive
Primitive:
They are of two types:
- Numeric
- Non-numeric
now,
Numeric :
They are of two types:
- Numeric
- Non-numeric
- Integer
- Floating point
- Integer
- Floating point
Non-numeric:
They are of two types:
- Character
- Boolean
- Character
- Boolean
Non-primitive:
They are of three types:
- Class
- Array
- Interface
explanation
INTEGER -Integer are whole number
byte 1 byte 0 -128 to 127
short 2 byte 0 -32768 to 32767
int 4 byte 0 -2147483648 to 2147483647
long 8 byte 0 -9223372036854775808 to 9223372036854775807
FLOATING POINT-A number containing fractional part
Data type Size Default Range
float 4 byte 0.0 3.40282347 x 1038, 1.40239846 x 10-45
double 8 byte 0.0 1.7976931348623157 x 10308, 4.9406564584124654 x 10-32
CHARACTER-A single character that is a letter ,a digit,a punctuation mark,a tab,a space and some thing similar to it.
Data type Size Default Range
char 2 byte \u0000 \u0000 to \uFFFF
BOOLEAN-Boolean are logical variable which can contain either TRUE/FALSE
Data type Value Default
char TRUE(1)/FALSE(0) FALSE
Data type Size Default Range
float 4 byte 0.0 3.40282347 x 1038, 1.40239846 x 10-45
double 8 byte 0.0 1.7976931348623157 x 10308, 4.9406564584124654 x 10-32
CHARACTER-A single character that is a letter ,a digit,a punctuation mark,a tab,a space and some thing similar to it.
Data type Size Default Range
char 2 byte \u0000 \u0000 to \uFFFF
BOOLEAN-Boolean are logical variable which can contain either TRUE/FALSE
Data type Value Default
char TRUE(1)/FALSE(0) FALSE
Saturday, August 18, 2018
Type of SD cards
classification of SD cards
There are mainly three sized SD cards
- Macro SD card
- Micro SD card
- Mini SD card
Macro SD card
These are larger in size then other and they are rarely used.| pic: Macro SD card |
Micro SD card
These are medium in size and normally used in mobile phone.
These cards are further divided into three types on the basis of size:
- SD card : There size starts from 0 GB to 4 GB.
| pic: SD card |
- SD HC card: There size starts from 4 GB to 32 GB.Here, HC stands for high capacity.

pic: micro SD HC
- SD XP card: There size starts from 32 GB to 2 TB.Here, XC stands for extended capacity.

pic: SD XC card
These cards are also further divided into different class on the basis of speed:
- class 2
- class 4
- class 6
- class 8
- class 10
- UHS 1 ( Ultra High Speed One)
- UHS 2 ( Ultra High Speed Two)
- UHS 3 ( Ultra High Speed Three)
| pic: micro SD HC |
| pic: SD XC card |
- class 2
- class 4
- class 6
- class 8
- class 10
- UHS 1 ( Ultra High Speed One)
- UHS 2 ( Ultra High Speed Two)
- UHS 3 ( Ultra High Speed Three)
The class of SD cards are written inside circle on the card.This class represent the maximum speed with which you can write data on the memory card.for example: class 2 means 2 Megabytes per second with which data can be stored on the memory.Now, UHS 1 and 3 support maximum speeds up to 320 megabytes.
Mini SD card
These are smaller in size then other SD cards and they are not generally used in normal use.
Friday, August 17, 2018
How to enable Intel VT-x in window 10 in Lenovo G series
Following step should be follow in order to enable VT-x setting
- You should shut down your PC.
- Now, near charging port there must be an small sized button,then click it.
- Menu appears, go to => BIOS setup => Configuration => Intel virtual technology ,then enable it if disabled.
- You should use UP,DOWN,LEFT,RIGHT key from keyboard to move cursor.
- If you want to select the option hit ENTER key.
- After this,you need to save this change by using shortcut key given in console.
- In exit saving changes,hit "YES".
- your computer begin start now automatically.
for more: CLICK ME
finally, you can enjoy VT-x enabled PC.
About Android Version
SOME OBSERVABLE POINTS ABOUT VERSION OF ANDROID
- Name of Android version are taken in such a way that belongs to name of chocolates and fruits around us.
- The first letter of Android version name is kept in increasing alphabetical order as increasing the versions of android.
- first version of Android was released on September 23,2008 .Initially it was given no name officially but people called it Alpha.
- Recent version of Android is "Android P" called "Pie" released on August 6,2018.
LIST OF ANDROID VERSION WITH RELEASED DATE ORDERLY
- Alpha 1.0 , released on 23-09-2008
- Beta 1.1 , released on 09-02-2009
- Cupcake 1.5 , released on 27-04-2009
- Donut 1.6 , released on 15-09-2009
- Eclair 2.0/2.1, released on 26-10-2008
- Froyo 2.2/2.2.3 , released on 20-05-2010
- Gingerbread 2.3/2.3.7 , released on 06-12-2010
- Honeycomb 3.0/3.2 , released on 22-02-2011
- Ice Cream Sandwich 4.0 / 4.0.4 , released on 18-10-2011
- Jelly Bean 4.1 , released on 09-07-2012
- Kitkat 4.4 , released on 31-10-2013
- Lollipop 5.0 , released on 12-11-2014
- Marshmallow 6.0 , released on 05-10-2010
- Nougat 7.0 , released on 22-08-2016
- Oreo 8.0/8.1 , released on 21-08-2017
- Pie 9.0 , released on 06-08-2018
Monday, August 13, 2018
SNAKE GAME IN C
Introduction:
If you want to develop snake game using C programming language then this blog obviously helps you.Hi i am Basant and i developed this game in my first year first semester project.
This is the project logo.
THERE IS CODE FOR THIS PROJECT WITH DOCUMENTATION:
Code:
Tools used:
- Dev-C++ IDE (Dev-Cpp 5.11 TDM-GCC 4.9.2 Setup)
- sublime text text editor ( Sublime Text Build 3170 x64 Setup)
Discussion:
Finally i just want a say take only idea from this code it might show some error while running in your PC since it does not produce Byte code as produced by Java.
If you want to ask something then comment below.
Watch in YouTube
Subscribe to:
Posts (Atom)


