Showing posts with label US. Show all posts
Showing posts with label US. Show all posts

Using String Variable with Kotlin Programming Language |Part-2|

String Variable with Kotlin

Greetings!

Hello Everyone here, Creating another video to demonstrate how to use String Variables in Android Studio using Kotlin Programming language.



 

Environment

Software: Android Studio
Programming Language: Kotlin

Summary

Its a beginner example and Part two of my Kotlin Programming Guide.

To declare any variable in Kotlin, you can simply use two keywords.

Var and Val

First, we are going to use Var Variables is the General variable that can be changed anytime throughout the Kotlin programming.

However, the Val variables are the constraint variables and can be declared only once.

Practice tasks

1. Open Android Studio and go to your project > Java > <com.folder> and edit the Kotlin file to create the variable:

fun main()
{
var name = "James"
val lname = "McDonald"
println(name)
println(lname)
}

Result: Run the compilation and see what happens, Check for error and update it here in comments.

2. Try to reassign a new value to the "var" variable name and the "val" variable lname and see if we can change the value at the later point during our program.

Result: Share the error, if any.

3.  Assign null values to the variables and check out for the outcome. Check for error.
Assign null String declaration to the available by using

:String? Next to the variable name.

Result: Share the error, if any.

We can also assign variables outside the function as well using this method variable will be easily accessible to the other Functions throughout the program.

While declaring the string variable, you may think about how the program decides what kind of variable it. Kotlin chooses the type of variable with very first user input. Like when you mentioned string value to the variable with the quotes that time it assigned, they string type to the variable, and that variable name will remain String Variable throughout the program.
Similarly, if we are going to assign Integer or Float value to the variable for the very first time, it will take is as the Float/Integer variable. We will discuss other types of variables in another post in more detail.

Kotlin - Control Statements |Part - 3|

Control Statements Part-3

In Kotlin Programming language, the Control Statements are similar as in most of the programing language.
Control Statements are the conditional statements that let us create a set of options to make a decision to produce the choice of output if a different type of input supplied to the program.




The Conditional Statements are 
  • if Statement
  • if-else Statement
  • if-else as expression
  • when Statement

if Statement: 

In an, if Statement, program checks for the Condition to match with the given option if matches then perform the activity following it

Syntax

if(<condition>)

{
    <Set of activity>
}

Example 1:

val name: String? = "James"
val lname = "McDonald"
var newVar: String? = null 
 
fun main()
{
if (name == "James")newVar = "Yes the name is " + name 
println(newVar)
}

Example 2:

var newVar: String? = null
var y = 20 
var x = 10
 
fun main() {
if (x > y) newVar = "x is greater number " + x
if (x < y) newVar = "Y is greater number " + y
println(newVar)
}


if-else Statement:

In an if-else statement, program checks for the Condition to match with the given option if matches then perform the activity follows it, if not matches the Condition, then conducts the other event.  

The syntax used for if the Statement is as below: 

if(<condition>) <Set of activity>
else <set of activity>

Example 1:

var newVar: String? = null
var y = 20 
var x = 10
 
fun main()
{
if (x > y) newVar = "x is greater number " + y
else newVar = "Y is greater number " + y
println(newVar)
}

Example2:

val name: String? = "James"
val lname = "McDonald"
var newVar: String? = null
fun main()
{
    if (name == "James")newVar = "Yes it is " + name
    else newVar == "No it is the Something else"

println(newVar)
}

if-else Statement as an expression:

In an if-else statement, it is just like the usual if-else Statement, but in this one, we use curly braces to supply multiple expressions instead of a single line of expression.

Syntax:

if(<condition>)
{
    <Set of activity>
}
else{
    <Set of activity>
}

Example 1:

val name: String? = "James" 
val lname = "McDonald"
var newVar: String? = null
fun main() { if (name == "James") { newVar = "Yes it is " + nameprintln(newVar) } else { newVar == "No it is the Something else"println(newVar) } }

Example 2:

var newVar: String? = null
var y = 20 
var x = 10
fun main() {
 
if (x > y)
{
newVar = "x is greater number " + y 
println(newVar)
}
 
else
{
newVar = "Y is greater number " + y 
println(newVar)
}
}

when Statement:

In a when Statement, program checks for the Condition to match with the multiple options to make a choice, when it matches one of the options, then it performs the activity following the decision.  

Syntax:

when(<variable>)
{
    <variable condition> -> <output>
    <variable condition> -> <output>
    <variable condition> -> <output>
    <variable condition> -> <output>
    else -> <output>
}

Example:

fun main() {
    when(x)
    {
        1 -> println("You selected  1")
        2 -> println("You selected  2")
        3 -> println("You selected  3")
        4 -> println("You selected  4")
        else -> println("Invalid range outside 1 to 4")
    }
}

Kotlin Program "Hello World" codded using Android Studio |Part-1|

Kotlin- Part 1

Introduction: 

 This article describes how to compline Kotlin programming inside the Android Studio for beginners tutorial.

Environment:

OS: Windows 10
Application: Android Studio

Description:

Kotlin is an alternative JVM programing language to create Android Application.

Most of the learners start learning Kotlin with IntelliJ and later start to work on Android Studio.

However, the learners can, from the beginning, learn this on Android studio.

In a small series of tutorials on Kotlin Programming, we introduced the tutorial to do a Kotlin Programming directly on Android Studio. In Part-1, we have a quick demonstration of running a "Hello World" program in the Android Studio application.

Kotlin Programming using Android Studio:




We welcome all our viewers to watch the video of the easy to use Kotlin programming to print "Hello World" into the Android Studio Terminal.

Some related questions:


What is IntelliJ?
Answer: IntelliJ is an Integrated Development Environment(IDE) software written in Java for making software. It was developed by Jetbrains(formally known as IntelliJ) in 2001 to Develop Java-based software with more sophistication; to learn more about IntelliJ history, please visit the Wiki link for IntelliJ.
What is Android Studio?

Android Studio is another IDE that is based upon IntelliJ and is specifically designed to create Android-based applications.
Wiki link to Android Studio.

What is Kotlin?

Java is a language that we still use to create as a preferred language to make Android applications. However, Jetbrains developed the programming language as an alternative to Java named it as Kotline, a new language buddle with more sophistication, ease, and it supports multiple platforms.
Wiki Link to Kotlin

 

What is the LifeSpan of Corona Virus on the surface of Mobiles, computers, and Gadgets?

The Novel Corona Virus COVID-19


The World Health Organisation (WHO) declared COVID-19 as the pandemic, and we know it is a global concern, and the impact is visible in many countries. The source of the Virus is still unknown. The scientists are estimating that it may have originated from China, where the first of such a case was reported and may be the result of the fact that Chinese people are habituated to it the animals who are the host of Coronavirus family, especially Snakes and Bats.  

Social Media Question

What is the full form of COVID 19?

Answer: Corona Virus Diseases, 2019.

Who is the Host of the Virus?

This Virus is not Airborn; that means it is not in the environment like regular viral flu, but it is a contagion that means it can be transferred from one patient to another patient.
We first need to understand how this Virus lives and survive in our body and how it infects others.

How This Virus Spread?

This Virus infects the lungs, nose, and throat; basically, the respiratory organs of the body, just like any other flu, show early symptoms of cough, cold, and flu. At a later stage, its cells start to regenerate inside the body at such a fast speed that it causes pneumonia and creates a life-threatening situation. Sneeze and cough cause tiny droplets containing the Virus, which is touched by the healthy person, and once his hand reaches around respiratory parts like nose or mouth, he infects himself.

Main Problem with this Virus - Why are we not able to control it?

This Virus survives for more than 3-4 days on the surface, and it is invisible due to which many people unknowingly come in contact with it and spread infection by infecting themself.

Why LockDown is the only resort?

Because we don't have a cure, the only way to survive is to break the chain of its spread by locking ourselves for the time all the patients are identified & quarantined.
Why we are not able to identify the patients without Lockdown. Most of the patients are showing the symptoms post 12 days during this period; they coughing and sneezing and laying the Virus on their surroundings.
Some people causing the further delay, because they are afraid and unaware of the situation, and the psychology of thinking that reporting the flu to the medical institutions which are full of COVID-19 patients is a hub, and they may get infected.
Delay in reporting of the decease cause delay in the treatment which results in an emergency, along with it there are chances of patients infecting a lot of people around him.
So it is crucial to lock ourselves for good 21 days or more if needed, completely isolate ourselves and in between if required medical help, report it immediately so that we can reduce the impact as soon as possible.

What is the lifespan of the COVID-19 Virus?

We should know the lifespan of this Virus on the surface of different objects, especially the necessary devices on which we spend most of our time & touch them again and again. 
For example, the surface of the table, knobs glass, water bottle, keyboard, mouse, power button, and switchboards, etc...
To answer this question accurately, we checked the report shared by WHO and sharing some details.
The old Report from World Health Organisation (WHO) suggested that the original SARS-CoV virus identified in the year 2003 has a lifetime on the glass surface for up to four full days, which makes it 96 hours.
For the Plastic Surface, it has a lifespan of 72 hours that makes it 3 days.
Similarly, In the recent study conducted by the United States' National Institutes of Health, and conveyed to the WHO reports that the new coronavirus (SARS-CoV-2) also lives on the surfaces like steel and hard plastic for about 72 hours (three days), same as the SARS-CoV virus.
Also, when tested on cardboard(you might be taking deliveries), it has a lifespan of 24 hours, and on copper, the Virus lives for 4 hours.
However, the new studies from the United States National Institutes of Health did not test it on Glass surface; hence we can consider the same as SARS-COV-2 as the other test factors match with COVID-19.
Finally, the best practice to be safe is social distancing and isolation for some time.
We give credit to the United States National Insitute of Health for sharing their research & providing us a better idea about the virus life span and helping us to be more aware of sanitizing the surface.
So far, We do not have any effective cure for the Corona Virus Pandemic, the only best way to rescue ourselves is by keeping the social distance between people, and by maintaining strict hygiene by covering ourselves with the protective shields like masks and sanitizer.

How to connect Nodes to Domain Controller.

You may have question how to Connect Node1 to DC ?

It is an easy task to perform, don't know why no one else created a proper blog about it.

First, you have to install 3 roles to the DC to make it Domain Controller and then it will be ready to add other nodes.

So the three roles are AD DC, DHCP, and DNS.

Add this three roles, then Promote your server as Domain controller create a Forest, give it a name and create NETBIOS.

Once it is done, go to Network adaptors settings and assign it a IP, you can assign class A, B or C, whichever you wish.

For example take class an IP address 10.1.10.1 and keep the default gateway and DNS server also the same.

Once you will assign the IP address now its time to set DHCP so that other computer will get the IPI addresses and will be able to connect to the domain.

So go to DHCP and right click on IPV4 and select New Scope option and create a scope and take range between 10.1.10.100 to 10.1.10.200.

Now we are done with the setting on DC.

Now need to connect Node one to the DC, so go back to the Node1 and in server manager select local server, in there click on manage IPV4 and now assign it any IP address which is within the scope and make the default gateway the IP address of the DC server.

Now go back to Server Manager click on Local Server and here click on "Workgroup" and change it to the domain name you had earlier assigned.

Now you will be able to connect the DC with the different nodes.

Found below video very useful to perform the above task and you can also proceed with performing clustering.

Video Courtesy : 

SrinathChowdary



How to configure NAT to share internet through DC to other nodes. Windows Server 2016

Sharing the internet through Domain Control to all other Workstation connected to it without much effort.

To configure sharing internet through one server to all the other machines in the network you need to configure NAT in Microsoft Windows Server 2012 and 2016.

So to do so you need to have two Lan Adapters installed on the Internet server.

Then install the Remote Access Server role. After installing it will ask for the prompt, just cancel that.

Go to the Routing and remote access here below server status you will be able to see the computer name of the local server which has the internet.

Now right click on it and select "Enable Routing and Remote Access" and then select option to make to do the customer configuration and create a LAN connection.

After it goes to the tools and select Windows Firewall and creates a new inbound rule to allow ping ICPSv4 to all the programs and computer.

Then come back to the Routing and Remote Access and here under the here right click on General under IPV4 and select create new routing interface select NAT.

After selecting NAT now its time to assign the interface, hence again right click on General and select the new interface and now select the external router which will be able to communicate with another machine in created routing mechanism.

Now you will be able to use the internet on all the computer associated within the domain.

And if you are using Hyper-V you will save a lot of time of adding the virtual switch. I found this video very helpful in doing the same if you are finding above instruction difficult you may watch below video: Video Courtesy: Professor Hornung

Activating Hyper-V inside the Virtual Machine.

To create Virtual Machine under the installed Virtual Machine using Hyper-V you have to make a note of following steps:



Step 1: Turn of the Virtual Machine.

Step 2: 
Run Powershell with Admin Right and enter below command:
Set-VMProcessor -VMName "<SERVERNAME>" -ExposeVirtualizationExtensions $true
In my case it was below:
Set-VMProcessor -VMName “Windows Server 2016” -ExposeVirtualizationExtensions $true
Like Below:

Step 3:
Ensure you have assigned minimum 4GB of RAM/Memory to the Virtual Machine. 

Step 4:
Network spoofing should be enabled while you are going to create the VM inside the VM so ensure its checked and enabled. 

If you are not going to follow this you might find below error: 

Error: Validation Result, Hyper-V Cannot be installed: The processor does not have required virtualization capabilities. 

So the above are the steps to make it capable enough. 

My First Virtual Machine : Installing Windows 2016 Sever on Windows 10 Pro Hyper-V, Step by Step Guide.

Hello, Technical Support Enthusiast, if you would like to learn another awesome stuff then here I am with "Installing Windows Server 2016" on Windows 10 through windows very own Virtual Machine Handler Hyper-V.

So first the boring stuff to tell you to have to install Hyper-V on the Windows 10 Pro.

The requirements, machine which is able to run Windows 10 Pro smoothly which drives it like butter like my computer (~_*) and Windows 10 Pro installed on it.

Once you have the above-detailed configurations please open "Turn Windows Feature On and Off" box like in below image:

Now you will get a kind of box which will look like a box in below image:

Now just like in above box select all the box and put a check mark next to them which has Hyper-V.

Now you have Hyper-V installed!

Now we will create our very own and very first Virtual Machine on Windows 10 Pro system.

Note: To do this I have downloaded the evaluation copy of Windows Server 2016 Datacenter edition on my computer which is free for 90 days.

Now open Hyper-V Quick Create like in below image:



:) You will be able to see below amazingly beautiful box once you are going to click on above box: 

Great, now things will be very interesting from here. So you already have two options from windows one is Windows 10 Developer Environment and another one is Ubuntu, Windows 10 Licence you already have so you can install a copy of that on the VM or you can install open source free Ubuntu.

As I am not in the mood of learning Linux today so I will bypass ubuntu and I already have the full-fledged version of Windows 10 Pro which is loading up things so I will excuse that too.

Please don't ask me how to download the Evaluation version of Windows 10 that will be a lot of effort for now. Just google it and do it by yourself.

So at this point, I am ready with my Windows 2016 Server ISO and I am going to select that instead of the above two options, so I am going to select "Local Installation Source" and going to follow the below options:

I believe you can understand the above instruction easily. Now click on Create Virtual Machine, and here you go:



Now click on connect and enjoy your Windows Server 2016 on your Windows 10 Machine.
This is a very useful method for MCSE enthusiasts who are learning it.

There are still a lot of things to discover in edit settings and then of course in a Virtual Machine world.

Hope you will enjoy your journey through it.

I have left some of the roadblocks on your ways to find a way through it, if you still find any difficulties please write in the comments box below I will get back to you, maybe sometimes in delay but I will surely going to get back to you on this.

All the best.





HyperV on Windows 10 Pro Error:An Error Occurred while attempting to connect to server "x-x" Check that the Virtual Machine Management service is running and that you are authorized to connect to the server.

Hyper-V Manager Error: An Error Occurred while attempting to connect to server "x-x" Check that the Virtual Machine Management service is running and that you are authorized to connect to the server. 

As you can see in below image and you can also check that on the left and side under Hyper-V Manager there is no server listed. 
As you have installed HyperV already and I believe that you have a brief understanding of what you trying to do, so I am not going to share much about the introduction of Hyper-V. 

So We will jump to the resolution of above. 

Just to add on to the above error I will also inform you that if you are going to select the option for HyperV Quick Create you will get the following in that case. Which will simply say Error: Not Found. 

To fix this issue, I had been to many forums. Some of the forums and blogs suggested a solution that one can try to uninstall windows feature and reinstall it and some PowerShell commands. 
If that could have worked for you then you should have stopped your search and there was no need to search further and come to my blog. 
And definitely, understanding that my blog is not so popular so far I can blindly believe that if your search has taken you to my blog that means you have already checked the possible resolutions and when you are not able to resolve it you are here at my blog post. 
So I will ensure if you have come so far then I will send you back happy!
So here is the fix: 
1: In Cortana, search box type in "WinVer" command and I bet it should be 1803 fall creator update. 
2: Now go to Windows feature and disable/uninstall Hyper V completely from there, restart the computer. 
3: Update windows to 1809.
4: Install Hyper-V again from Windows Feature after the windows update. 
Now, your issue is resolved. 
Just in case it is still not working, Let me know I tried something else in between which just made it worked like charm, but as of now I don't think that step is needed so please just proceed with above steps and for further support do feel free to write in comments below. 
I really appreciate you writing and raising your concern. 
I really don't care about likes and share, my belly is already stuffed to fullest. :) Thanks to God. 



Enter your email address:

Delivered by FeedBurner